Signal error to msbuild that a unit test has failed

Signal error to msbuild that a unit test has failed

How can NCover.console pass the return value (errorval) from nunit-console to msbuild so that the CruiseControl tray indicates a red or build failure.

Our unit tests are executed but a couple fail...the CC tray is green...we would like it to be red.


Re: Signal error to msbuild that a unit test has failed

NCover.Console returns the return value of the process it is profiling. If you are running NUnit-console as your profiled process, then NCover.Console should be returning whatever it gets back from NUnit.


Re: Signal error to msbuild that a unit test has failed

Thanks. I actually tried checking for the return value and flagging it as an error using the snippet below in my msbuild project. However. it still shows the build as good even though some unit tests failed. Do you have any idea; I will need to troubeshoot it eventually...Thanks

<Exec ContinueOnError='true' Command='"$(NCover)" //x Coverage.xml "$(unitTest)" "E:\KTBS\Solutions\Misc\KTBS.Service.nunit" "/domain=Multiple" "/nologo" ' WorkingDirectory='E:\KTBS' >

<Output TaskParameter="ExitCode" ItemName="ExitCodes"/>

</Exec>

<Error Text="Unit Test error occurred" Condition="'%(ExitCodes.Identity)'>0"/>


RE: Signal error to msbuild that a unit test has failed

setting "ContinueOnError=false" should do the trick for you, but if for some reason that's not possible, you could also check out NCoverCop

http://www.nigelthorne.com/blog/2007/11/ncovercop-trunk-for-coverage.html