views:

20

answers:

2

When I run my MSTest tests in Visual Studio 2008 Team System and get code coverage results, I always see a particular web service included. I don't care how well this web service is tested, I'm intentionally only using a small part of it. How can I exclude the Web Reference from showing up in my Code Coverage results?

I see that someone asked this very question over on Microsoft Connect and it's marked as postponed, but I was hoping someone knew of a workaround.

+1  A: 

A work-around would be to put the web service in a separate assembly and not run code coverage on that assembly/project.

klausbyskov
That seems janky as hell, but it worked. I hope in the future they come up with a way to exclude web services from code coverage so that you don't have to do this.
Sarah Vessels
A: 

I do not believe this is possible in the current version of the code coverage feature. It will report the code coverage results for the entire assembly.

One thing you could try is to tag the Web Reference with the DebuggerNonUserCode attribute. This is used by several tools to filter out code that is not actually owned by the user. I do not know if the code coverage tool filters this attribute but it's possible that it does.

JaredPar
Someone mentioned using that attribute on a class, but how would I do it for a Web Reference? If I try to open the Web Reference, it just shows me stuff in the Object Browser.
Sarah Vessels
@Sarah: you might try creating another part of the partial classes generated by the web reference. Put the attribute on the other part. Keep the other part in a folder other than the web reference folder.
John Saunders