Domanda

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>
È stato utile?

Soluzione

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".

Altri suggerimenti

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

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.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top