ServiceWatcher: A New Way to Manage Service Coverage

ServiceWatcher: A New Way to Manage Service Coverage

The wizards at NCover have done it again.

Introducing ServiceWatcher…have you ever wanted to cover multiple services during a test but didn’t want to have to start / stop them all manually? If you’re in an environment that can’t tolerate service interruption, you’ll want to check out this simple and FREE solution.

ServiceWatcher lets you cover any service(s) multiple times on a test run. Start and stop services and gain coverage data on every iteration without having to restart tests. ServiceWatcher is a .NET application that utilizes configurable bat scripts for coverage runs. The scripts are completely reconfigurable so that your team can personalize them for its unique build / test process. Just follow along in the comments and you’ll be testing like a pro in no time.

Download: http://downloads.ncover.com/ncover.servicewatcher.zip

Here are some instructions for getting started.

Starting

To start coverage, browse to and run the NCover Core Services - cover services.cmd. This will open a command prompt that will start all the services under the service watcher and NCover coverage.

Stopping

  1. Run the Kill_Service_Watchers.cmd.
  2. Run the NCover Core Services - stop services.cmd.
  3. CTRL-C stop the batch file in the command window where coverage is running.
  4. Close the coverage command window if it doesn't close automatically. The window may linger while completing the final coverage collection, so waiting for it to close on its own is best.

What the Files Do:

The following is a description of each of the files inside the .ZIP file for download.

ncover.servicewatcher.exe:

This executable is the core of the coverage process, restarting coverage on the desired services. NCover collects coverage by monitoring the service. Whenever NCover exits for a given service, the watcher will restart NCover on that service. When the service stops, NCover writes the coverage and trend data.

To cycle collection of data on services then the service must be stopped. NCover will collect coverage data. And then the watcher will restart NCover when the last NCover process completes for that service. Source code for this utility is provided without expressed or implied warranty. Use and modify as needed for your purposes.

NCover Core Services - cover services.cmd:

This batch file starts NCover coverage for all of the services and outputs the data and logs to c:\ncoverdata location. This path can be modified to a location of your preference. It is implemented with a single command that is reused for all services.

The command is located at the :coverService label in the batch file. Add additional NCover options here. The coverage for each service is collected to a separate nccov file. The trend data is collected to a shared trend file. If you need to specify a project name or other NCover options you can do so in this command.

Be sure to quote the values so that odd filenames don't break the command line (e.g., //x "%COVERAGE_PATH%\%2_[time].nccov"). Variable %1 is the service name in windows. %2 is the file name stub you want to use for that service. There is a second coverage command in this section, which has been commented out.

NCover Core Services - stop services.cmd:

A shortcut to stop all the services under coverage. This script is helpful when you just want to stop all coverage.

Kill_Service_Watchers.cmd:

A shortcut to kill all the ncover.servicewatcher.exe processes that are currently running. This script is needed to turn off coverage once it has begun. Otherwise as each service stops the watcher will just restart it.

Send us some feedback when you're done.