No coverage report produced with MbUnit console
No coverage report produced with MbUnit console
I am currently switching to MbUnit and i was wondering why my Nant NCover task is not producing any reports to my report folder.
Here is a snippet of my build file:
<target name="run-unit-tests">
<mkdir dir="${build.dir}\test-reports" />
<!-- set unit test parameters -->
<property name="report.dir" value="${build.dir}\test-reports"/>
<property name="mbunit.exe" value="${tools.dir}\MbUnit\MbUnit.Cons.exe" />
<property name="nunit.exe" value="${tools.dir}\NUnit\nunit-console.exe" />
<property name="unittest.working.dir" value="${build.dir}\Debug\UnitTests" />
<property name="nunit.parameter" value="Elcs.UnitTests.dll /xml:${report.dir}\UnitTests.xml /nologo" />
<property name="mbunit.parameter" value="Elcs.UnitTests.dll /ap:${unittest.working.dir} /rf:${report.dir} /rnf:UnitTests{0}{1}" />
<property name="mbunit.parameter2" value="Elcs.UnitTests.dll" />
<!-- set code coverage parameters -->
<property name="coverage.assemblies" value="Elcs.Core;Elcs.WinUI" />
<call target="unit-tests-with-code-coverage" /> <!-- unit tests without code coverage -->
<!-- <call target="nunit-tests" /> unit tests without code coverage -->
</target>
<target name="nunit-tests">
<exec program="${nunit.exe}" workingdir="${unittest.working.dir}">
<arg line ="${nunit.parameter}" />
</exec>
</target>
<target name="mbunit-tests">
<exec program="${mbunit.exe}" workingdir="${unittest.working.dir}">
<arg line ="${mbunit.parameter}" />
</exec>
</target>
<target name="unit-tests-with-code-coverage">
<exec program="regsvr32" workingdir="${tools.dir}\NCover" commandline="/s CoverLib.dll" />
<ncover
program="${tools.dir}\NCover\NCover.Console.exe"
commandLineExe="${mbunit.exe}"
commandLineArgs="${mbunit.parameter2}"
coverageFile="${report.dir}\coverage.xml"
logLevel="Normal"
verbose="true"
workingDirectory="${unittest.working.dir}" >
<assemblies basedir="${unittest.working.dir}">
<include name="Elcs.Core.dll"/>
<include name="Elcs.WinUI.dll"/>
</assemblies>
</ncover>
<!--<ncover
program="${tools.dir}\NCover\NCover.Console.exe"
commandLineExe="${nunit.exe}"
commandLineArgs="${nunit.parameter}"
coverageFile="${report.dir}\coverage.xml"
logLevel="Normal"
workingDirectory="${unittest.working.dir}" >
<assemblies basedir="${unittest.working.dir}">
<include name="Elcs.Core.dll"/>
<include name="Elcs.WinUI.dll"/>
</assemblies>
</ncover-->
</target>
Re: Need help with the NCover exclusions using command line
Have you see this blog posting by Jamie Cansdale?
http://weblogs.asp.net/nunitaddin/archive/2006/10/04/CoverageExclude.aspx
With the syntax above it is important that the CoverageExcludeAttribute is defined without a namespace. If you put it inside a namespace then you must include that in the name passed with //ea.
Re: Need help with the NCover exclusions using command line
Thanks. That helped. Is there any way to specify some files or name spaces in the commnad line to exclude instead of modifying the code to use attributes?
Re: Need help with the NCover exclusions using command line
Not using NCover. You can however using NCoverExplorer - it allows exclusions currently at the assembly, namespace and class level. There is a request by someone for method level exclusions too, but that will have to wait until I add support for multiple projects.
Re: Need help with the NCover exclusions using command line
How do you use exclusions with NCoverExplorer for a namespace?
I am testing an data access assembly (ABC.dll) that has designer built datasets that are all of the namespace ABC.DataSets. While my actual primary classes of this assembly are 100% tested, due to the DataSet classes (especially for Row and RowChangedEvent's) my total coverage is only 19%.
thanks
Adam
Re: Need help with the NCover exclusions using command line
That depends - are you using the GUI or the console? If the latter, are you using an exec, NAnt or MSBuild task? There are examples in the documentation for NAnt/MSBuild, if using the exec approach look at ConsoleExample.config, and if using the GUI just hit F2 and choose the Exclusions tab.