How to cover webservices

How to cover webservices

Hi,

I have an application which consists of an application layer written in C# 1.1, and then a data layer which is all ASP.NET 1.1 webservices. I have NUnit tests in my application layer and I get coverage of all the code in these assemblies.

The problem I'm having is getting any coverage on the webservices which provide all of my data access.

Can anyone explain how to do this?

I thought it might be by using the //iis switch...so start covergage with //iis, then run all my tests and then stop IIS to generate the coverage results. However, I get this when I simply navigate to one of the webservice asmx pages:

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

Any help greatly appreciated!

Paul


RE: How to cover webservices

Paul,

You're profiling webservices the way you should, with the //iis switch. What does your log file say?

Stephen


RE: How to cover webservices

Hi Stephen,

No coverage.log file is generated at all.

Is there another log file I should be looking at?

Thanks,

Paul


RE: How to cover webservices

no, coverage.log is the only log that gets generated. Which version of NCover are you using? If it's 2.0 or higher, you'll have to include the //l switch to get a log file.

Stephen


RE: How to cover webservices

Just picking this up again....

I'm using NCover 1.5.8


RE: How to cover webservices

no coverage is quite odd. We haven't tested the webservices bit with 1.5.8 but it should work the same as 2.0, which we have tested. If possible, try telling NCover to create a verbose log file with the //l and //v switches. If that doesn't create a log file then you shouldn't get a coverage.xml either. If you do get a coverage file, then something wierd is going on and we'll have to dig deeper.

Stephen


RE: How to cover webservices

Hi Stephen,

Thanks for getting back to me so quickly.

I used the command:

   ncover.console //iis //v //l <log> 

and it generated no log file and no coverage file.

When I ran the command it first said:

"The Waiting for the profiled application to connect..."

and just sat there waiting as you would expect.

I then fired up NUnit and kicked off my tests which call the webservices. As soon as it calls the first webservice the NCover console displays:

"...Connected No value exists with that name."

And definitely no log file or coverage file.

Many thanks, Paul


RE: How to cover webservices

Paul,

You can work around this bug by adding a key to the registry.

under "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" add "NCover_Process_Module"

the value of the key doesn't matter

Regards, Stephen Ward


RE: How to cover webservices

Hi Stephen,

I added that key to the registry but still got the same problem.

I wondered if you meant add it as a Value rather than a Key so I tried both, and rebooted just in case.

But I'm still getting the "No value exists with that name" error.

Thanks,

Paul


RE: How to cover webservices

Paul,

I did mean a Value. My apologies for the confusion. I'm not sure why you're still running into the problem; are you running NCover multiple times? Anyway, I've emailed you a fixed version of the 1.5.8 dll that should solve the preoblem.

Stephen


RE: How to cover webservices

Hi Peter,

YES!!!!! You Sir, are an absolute legend! The DLL you emailed over to me solves the problem!!

I've now run into something else I hope you can help me with...

If I run ncover.console //iis manually, run my NUnit tests through the NUnit front end (or command line nunit-console.exe), then go back to the ncover.console window and hit Ctrl-C I get the coverage and all is well.

I am getting problems, however, with running this through a NAnt script. I found the documentation on the task. This is my NAnt target:

When I run it I get the following output:

[ncover] NCover.Console v1.5.8 - Code Coverage Analysis for .NET - http://nco ver.org [ncover] Copyright (c) 2004-2006 Peter Waldschmidt [ncover] Command: nunit-console.exe [ncover] Command Args: BRIT_NUnit.nunit [ncover] Working Directory: [ncover] Assemblies: [ncover] Coverage Xml: coverage.xml [ncover] Coverage Log: coverage.log [ncover] Starting IIS [ncover] The profiler will not connect until you load an ASP.NET page. [ncover] Press Control-C when you are finished to stop IIS and collect covera ge data. [ncover] Waiting for profiled application to connect...Connected DELAY OF AROUND 60 SECONDS HERE [ncover] Profiled process terminated. Profiler connection not established. BUILD FAILED C:\BRIT\default.build(14,3): External Program Failed: C:\Program Files\NCover\ncover.console.exe (return code was 1) Total time: 70.3 seconds.

(note that it runs the tests OK without the profileIIS="true")

I found a few posts regarding this problem so I tried a couple of things. Namely:

  • Granted full control to "Everyone" on the registry key HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment (not a good idea I know but I wanted to rule out a security issue on this key)
  • Re-registered coverlib.dll from the directory where NCover is installed (just in case)

No joy though. Am I doing something wrong?

Sorry for the "noob" questions but I'm struggling. I really appreciate all the time you're spending helping me!

Paul


RE: How to cover webservices

Paul,

Does the error show up when you run, not through the NCover specific task, but through a NAnt Exec task? What version of the CLR is on your computer? I don't think you mentioned this; do you get a coverage.xml when the error happens? Are you running on a 32-bit OS?

Stephen Ward


RE: How to cover webservices

How to call ncover //iis from nant file as it asks for clicking cntrl-c. So can "ncover.console.exe //iis " be used for web application code coverage as I am using this tool for continuous intergration with nant file so that one would be able to perform automated testing and identifying code coverage of web application with that test scripts.


RE: How to cover webservices

Sorry to jump in, but I'm having the same problems. I'm using NCover v1.5.8, and when I use the //iis switch, no log or coverage file gets generated. I have tried adding the "NCover_Process_Module" value into the registry location sporewell has specified. Although I no longer get the "No value exists with that name" error message, I am not getting any results (log file or coverage file). Also, I am now getting the message "Profiled process terminated. Profiler connection not established."

Also, what type of registry value should "NCover_Process_Module" be? I've tried all types, but it'd be nice to know whether it should be a string, binary, DWORD, QWORD, multi-string, or expandable string?


RE: How to cover webservices

I'm running into a different problem. The registry valuee gets deleted after every run. Is this an expected behavior?

During the run thee NCover_PID is visible. After the run though the "NCover_Process_Module" key gets deleted as well.


RE: How to cover webservices

That behavior would be expected, because NCover cleans up its environment after each run.


RE: How to cover webservices

I'm having the same problems. I'm using NCover v1.5.8, and when I use the //iis switch, no log or coverage file gets generated. I have tried adding the "NCover_Process_Module" value into the registry location sporewell has specified. Although I no longer get the "No value exists with that name" error message, I am not getting any results (log file or coverage file).

Would you email me a fixed version of the 1.5.8 dll that should solve the problem?


RE: How to cover webservices

Hi, mogawa. We no longer support v1.x. You can start a free 21-day trial of NCover v3.4 by downloading it at www.ncover.com/download. That should give you the results you're looking for. Please tell us about any questions you have on upgrading to 3.4. Drop us a note at support@ncover.com. Thanks!