3

My unit tests are being executed and reports written, however the coverage reports are empty. This is the Nant task I'm using:

<target name="unitTests">
    <foreach item="File" property="filename">
        <in>
            <items>
                <include name="**\UnitTestBinaries\*.UnitTests.*.dll"></include>
            </items>
        </in>
        <do>
            <exec program="${ncover-console}" 
                  workingdir="${path::get-directory-name(filename)}" 
                  commandline="&quot;${nunit-console}&quot; ${filename} /xml:${project::get-base-directory()}\_nunit_${path::get-file-name-without-extension(filename)}.xml /nologo //x ${project::get-base-directory()}\_ncover_${path::get-file-name-without-extension(filename)}.xml" 
                  failonerror="true"
                  verbose="true"/>
        </do>
    </foreach>
</target>

Any ideas why I'm not getting coverage data? Is there any easier way to achieve this step?

Thanks for any help.

Edit:

This is an example output file:

<!-- saved from NCover 3.0 Export url='http://www.ncover.com/' -->
<coverage profilerVersion="3.3.0.6070" driverVersion="3.3.0" exportversion="3" viewdisplayname="" startTime="2011-10-31T23:27:33.3688015Z" measureTime="2011-10-31T23:27:36.1420615Z" projectName="" buildid="d3a76074-bb16-4677-8273-91c7b6552066" coveragenodeid="0" failed="false" satisfactorybranchthreshold="95" satisfactorycoveragethreshold="95" satisfactorycyclomaticcomplexitythreshold="20" satisfactoryfunctionthreshold="80" satisfactoryunvisitedsequencepoints="10" uiviewtype="TreeView" viewguid="C:\_documents\CI\_ncover_XTFL.UnitTests.Core.xml" viewfilterstyle="None" viewreportstyle="SequencePointCoveragePercentage" viewsortstyle="Name">
  <rebasedpaths />
  <filters />
  <documents>
    <doc id="0" excluded="false" url="None" cs="" csa="00000000-0000-0000-0000-000000000000" om="0" nid="0" />
  </documents>
</coverage>

Edit II:

This is a sample of the buildlog output (edited for security):

<task name="ncover">

                <message level="Info"><![CDATA[Command: C:\Program Files\NUnit 2.5.10\bin\net-2.0\nunit-console.exe]]></message>
                <message level="Info"><![CDATA[Command Args: C:\_documents\CI\Working\UnitTestBinaries\XTFL.UnitTests.Workflow.dll /xml:C:\_documents\CI\_nunit_XTFL.UnitTests.Workflow.xml /nologo /noshadow]]></message>
                <message level="Info"><![CDATA[Working Directory:]]></message>
                <message level="Info"><![CDATA[Assemblies: (All Loaded Assemblies)]]></message>
                <message level="Info"><![CDATA[******************* Program Output *******************]]></message>
                <message level="Info"><![CDATA[ProcessModel: Default    DomainUsage: Single]]></message>
                <message level="Info"><![CDATA[Execution Runtime: Default]]></message>
                <message level="Info"><![CDATA[..........]]></message>
                <message level="Info"><![CDATA[Tests run: 10, Errors: 0, Failures: 0, Inconclusive: 0, Time: 0.9677115 seconds]]></message>
                <message level="Info"><![CDATA[Not run: 0, Invalid: 0, Ignored: 0, Skipped: 0]]></message>
                <message level="Info"><![CDATA[***************** End Program Output *****************]]></message>
                <message level="Info"><![CDATA[Execution Time: 2.8983 s]]></message>
                <message level="Info"><![CDATA[Coverage Xml: C:\_documents\CI\_ncover_XTFL.UnitTests.Workflow.xml]]></message>
                <duration>3278.1105000000002</duration>
              </task>
MalcomTucker
  • 7,407
  • 14
  • 72
  • 93

3 Answers3

1

If your NCover license allows, recommend upgrading to 3.4.18.

Based on the messages alone, it looks like profiling never begins on your NUnit process.

I can't see the exact command line syntax from the NAnt task, but NCover has to start NUnit in order to profile the unit test DLL.

If NCover is starting NUnit successfully, you should see a message after the "Program Output" that says, "Process 'nunit-agent' [PID 3116] has begun profiling" before the NUnit test results, and another message after the results that "Process 'nunit-agent' [PID 3116] has finished profiling".

NCover Support
  • 271
  • 1
  • 4
  • Thanks for the info, much appreciated. Just so I understand, is it possible for the tests to run (because I think they do) and the profiler not run/attach even though NUnit was started via NCover? Is there a command line argument I need? – MalcomTucker Nov 01 '11 at 22:37
  • I agree that it looks like the tests are running, but NCover isn't profiling. If you are starting NUnit with NCover, like this, for example: ncover.console.exe nunit-console.exe TestAssembly1.dll /nunit args //ncover args NCover should automatically detect the nunit exes, but try this arg in your NCover command line to specify those processes: //pn nunit-agent.exe //pn nunit-console.exe Or, //pn nunit-agent-x86.exe, if you're running the 32-bit version. Speaking of bits, make sure you're running the same bitness of NCover and NUnit, though you should get an error message if you aren't. – NCover Support Nov 02 '11 at 13:46
1

I remember having a similar problem. Are you placing the related .pdb files besides the assembly files? That solved it for me.

The Chairman
  • 7,087
  • 2
  • 36
  • 44
0

That's a good tip re: the PDB files, but even without them, you should get Branch coverage, though you won't get any Symbols.

NCover Support
  • 271
  • 1
  • 4