Problem when using Ncover with ASP.NET app.

Problem when using Ncover with ASP.NET app.

Hi,

I am using v1.5.8 of Ncover with XP/IIS and ASP.NET 1.1. When I run Ncover.console.exe //iis, I get all the expected messages until I run the ASP.NET application. At this point I get the message "No value exists with that name" appearing just before Ncover exists.

Is this a problem, or more likely, what I am doing wrong?

Thanks.


Re: NCover fails from MS Build

Hi Craig,

I can't comment about running it from MSBuild so much but the issue is not NCover so much as NUnit. If you were to run NUnit directly (certainly from NAnt) then the exit code being returned as a result of a test failure will result in a failure in your build script. NCover likely just passes through the exit code hence the behaviour you are seeing all makes sense.

The question to be asked is - what is it you want to do after your tests fail? The frequent approach is to allow the build script to terminate, and if you have other actions you want to perform then you do them in the <publishers> section of your CruiseControl project (which get run regardless of success/failure).

If you wanted a more meaningful error message added to the output (which I do with a NAnt based script) then in NAnt there are try/catch tasks and onfailure properties you can use to handle this situation and allow your script to continue.

I don't know off the top of my head what the equivalent in MSBuild is - and you havent stated why the above actually causes you a problem? Incidentally are you using the <Exec> task or my <NCover> MSBuild task from NCoverExplorer.Extras.zip?

If I've missed a key point about your particular situation my apologies.

 


Re: NCover fails from MS Build

Good morning,

Thanks for your reply.

That all makes perfect sense and was an enourmous help in finding the solution.

I can see why you would usually want a build to fail if the tests do, however in my situation we would like to run NCover to get the code coverage, and then run NUnit to get the test results. This way we get a new code coverage report for each build regardless of unit test failures. NUnit will then report the test failures separately and fail the build. Unless I am missunderstanding things, this should provide the most complete information for each build.

As is often the case with these things, the solution is easy - it's just a case of finding it. Your explaination of how the errors are passed, and how you achieve this with NAnt put me on the right track. Basically, if you add the 'ContinueOnError' attribute to the NCover task, MSBuild will swallow the error and spit it out as a warning, therefore not failing the build.

So for the benefit of anyone trying to find the solution to this, in my example the NCover task looks a bit like this:

<Target Name="NCoverRun">

<NCover ToolPath="C:\Progam Files\NCover" CommandLineExe="C:\Program Files\NUnit-Net-2.0.2.2.7\bin\nunit-console.exe" CommandLineArgs="C:\Projects\MyProject\MyProject.nunit" CoverageFile="C:\Projects\MyProject\Coverage.xml" WorkingDirectory="C:\Projects\MyProject" ContinueOnError="true" />

</Target>

For more information on handling errors in MSBuild, have a look at Kevin Dente's blog:  http://weblogs.asp.net/kdente/archive/2005/07/19/419973.aspx

Many thanks again for your help!

Cheers

Craig


RE: Problem when using Ncover with ASP.NET app.

Hi it seems replies to the original thread have been mixed up.

I am getting the problem stated in the original post - I can't use NCover 1.5.8 to get coverage results from an ASP.NET application.

I start NCover with the //iis switch and I get the messages saying it's waiting to connect. Then when I navigate to my webpage (it's acutally a webservice) the console shows:

"Waiting for profiled application to connect...Connected No value exists with that name."

Does anyone have a solution to this?

Or any other advice on how to get coverage stats for a webservice?

Thanks, Paul


RE: Problem when using Ncover with ASP.NET app.

Paul,

We've greatly improved NCover in regards to collecting coverage data with IIS in NCover 2. I highly recommend checking it out.

Alan Johnson NCover Team


RE: Problem when using Ncover with ASP.NET app.

How to integrate ncover /iis in nant file??