Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Webservice coverage with NCrunch, possible?
JoaoMLH
#1 Posted : Monday, September 10, 2012 11:06:49 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 9/10/2012(UTC)
Posts: 3
Location: Munich, Germany

Thanks: 1 times
Was thanked: 1 time(s) in 1 post(s)
Hi everybody,

first of all let me say that this is the best Visual Studio plug-in for Testdriven programming.
It is a UnitTester and a Coverage tool all in one :)
This helps any developer check what use-case hasn't been tested yet, and what code might cause be causing problems in the future.

Anyway we are currently developing a lot with Webservices (WCF) and unfortunetly I cannot get NCrunch to check the code of the webservices.
The nice green/black/red circles all appear black in the Webservice c# code, allthough there are Testcases (where the circles are green).

Could I be doing anything wrong?
Or does NCrunch simply not support Webservice code coverage?

Thanks for any help!

Regards,
Joao
Remco
#2 Posted : Monday, September 10, 2012 11:18:11 AM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,144

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
Hi Joao,

Thanks for posting! And I'm glad your enjoying the tool.

Right now, I can think of two things that could cause the behaviour you've described:

1. You have a test project that is referencing your runtime code using an assembly reference instead of a project reference (NCrunch requires project references in order to identify code that is part of the solution)

2. You have integration tests that are covering the web service code by testing across multiple processes and/or application domains. Right now NCrunch doesn't support code coverage for cross-process testing, as this means correlating coverage data across multiple processes and sending them back to the test runner (which I'm hoping to add in future). The only real way around this is to try to test the bulk of your logic with unit tests that do not traverse process or application domain boundaries (which is generally better practice anyway), you can then use the integration tests basically just to check whether the wiring is OK.

Do you think either of the above cases may apply to your solution?


Cheers,

Remco
1 user thanked Remco for this useful post.
JoaoMLH on 9/10/2012(UTC)
JoaoMLH
#3 Posted : Monday, September 10, 2012 11:44:58 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 9/10/2012(UTC)
Posts: 3
Location: Munich, Germany

Thanks: 1 times
Was thanked: 1 time(s) in 1 post(s)

Hi Remco,

wow impressive, that was the fastest useful response ever. :)

I was confusing Integration tests with Unit tests, that was why NCrunch wasn't doing what I was expecting.
I was testing across multiple processes, I guess, because one is the process where NCrunch is running the testcases and the other one is the one were the WCF Webservices are running (w3wp.exe).

Taking your advice of testing the webservice directly (without invoking the WebReference methods) NCrunch can now keep coloring my code :)

Thanks a lot Remco.

Best regards,
Joao
1 user thanked JoaoMLH for this useful post.
Remco on 9/10/2012(UTC)
wilhelmmedetz
#4 Posted : Tuesday, September 11, 2012 11:41:04 AM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 7/4/2012(UTC)
Posts: 35

Was thanked: 2 time(s) in 2 post(s)
If your web service is a WCF service you could self-host the service inside your test project.
Then you will get code coverage results for the WCF service.

Integration testing WCF self Hosting would also allow you to test additional functionality like:
* Fault behavior
* Service reference implementation
* SessionMode behavior

The disadvantage is, that hosting the service in the same process for different tests can have side effects and can be a little bit tricky.

I am currently using this approach with NCrunch successfully for several WCF services.

Regards

Wilhelm
JoaoMLH
#5 Posted : Tuesday, September 11, 2012 12:35:04 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 9/10/2012(UTC)
Posts: 3
Location: Munich, Germany

Thanks: 1 times
Was thanked: 1 time(s) in 1 post(s)
Hi Wilhelm,

thanks for the reply.
I'll give self-hosting a webservice a try.

Here was is article about it:
http://dotnetstories.wor...f-hosting-wcf-services/

I hope it works.

Best regards,
Joao

Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

YAF | YAF © 2003-2011, Yet Another Forum.NET
This page was generated in 0.043 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download