how to cover spawned process from commandline

I am trying to use the commandline to measure coverage for a client-server setup. I would like to have coverage data for both server and test-client. The command line will be executed from a Jenkins build-server.

It does not look like the command tool supports this setup? I can find some documentation for how to do this manually using the GUI from inside VS but not for the command line.
I have tried to use nant as a target and let it spawn processes, but it does not pick up coverage data for the server. This is only partly true, because it picks up coverage data from the server when it is run as a normal non-spawned process.

Is it possible fom the command line to get coverage data from a spawned process at all?

The dotcover configuration file is


And the nant target looks (simplified) like this

<target name="test.functional.mssql">

<exec program="server\bin\${}\${configuration}\my.server.exe"> <-- this is in-process and dotcover picks up coverage data.
  <arg value="-install" /> <-- this makes the sever stop after the installation

<exec program ='server\bin\${}\${configuration}\my.server.exe' spawn='true' pidproperty='' /> <--this spawns the server, which runs until killed

<exec program="tools\NUnit-2.5.10\bin\net-2.0\nunit-console-${}.exe">
    <arg value="test\FunctionalTests\bin\${}\${configuration}\FunctionalTests.dll"/> <-- dotcover picks up coverage for this and the client assemblies that are loaded by the test

<kill pid="${}"/> <--stops the server



Permanently deleted user
Comment actions Permalink

Hello Jeppe,

I think that the problem here is with "kill" task: dotCover can't get coverage data if a process being analyzed was terminated abnormally (was killed or crashed, e.g. due to an unhandled exception). Your scenario would work if you could stop your server gracefully. For instance, you can introduce something like a special "stop" server command.

Please do not hesitate to contact me if you have any questions. Best regards.

Comment actions Permalink

Hi Ekaterina

Thans for the quick reply!

Alas, there is no way I can add stop-functionality to the server. It is a large and mission-crititcal product with all kinds of QA and red tape for introducing new functionality.

But it runs as a Windows Service when deployed. So I tried

        <exec program="net">
          <arg value="start"/>
          <arg value="My Server"/>

for starting and

      <exec program="net">
          <arg value="stop"/>
          <arg value="My Server"/>

for stopping.

The nant also installs the service through a <exec program "sc.exe" .../> task

The nant script runs correctly, but no luck in getting coverage data..

I am considering whether I should try to make a custom nant task, which holds an object which instantiates the main server class and somehow retains the object for later garceful closiing, but that is a long way to go. Any further ideas are most welcome.

Cheers, Jeppe
Permanently deleted user
Comment actions Permalink

Hi Jeppe,

Unfortunately now dotCover's command line tool can analyze only standalone applications. It gets coverage data from the main application process and its child processes. That's why it failed to obtain coverage data from the service in your last experiment. We are planning to add other types of analysis to the console runner, but not in the nearest release. In particular, we are planning to add possibility to analyze all .Net processes that start while the console runner is working -

Sorry for the inconvenience. Best regards.


Please sign in to leave a comment.