Alex Rivera | Logout

How to get code coverage when testing Silverlight

Asked 2009-09-05T17:59:10.990
15

I'm looking for code coverage solution which works with silverligt. It must also work with msbuild because we run all the other unit tests automatically in the build server.

Integration with Visual Studio and/or resharper is a plus and I have nothing against easy setup or a pointer to a tutorial. I don't usually modify the build files and unfortunately I don't have time to learn msbuild at the moment.

Edit
Report

2 Answers

1

To clarify previous posts, NCover can cover any .NET process ONLY. It does not yet handle the Silverlight CLR. In the cases presented above, one user asked about a .NET test framework that fires off his .NET tests that run against his Silverlight application. Anything .NET (e.g., the test framework) will be covered in this scenario. Silverlight code WILL NOT be covered.

answered 2011-02-22T15:22:58.580
0

I asked this from NCover support.

My question was:

Lets say I create a silverlight class library (Project -> New Project...) from Visual Studio. In this class library I have several classes and I use the NUnit silverlight template to project which contains unit tests for my silverlight class library:

http://weblogs.asp.net/nunitaddin/archive/2008/05/01/silverlight-nunit-projects.aspx

I am able to run unit tests just fine (even in the build server, we are using msbuild and TFS) but I cannot get code coverage data for them using the standard code coverage options that are available in Visual Studio.

Can NCover show the code coverage for my silverlight class libraries?

Response I got:

As long as you're testing the class libraries with NUnit, you should be able to cover them using NCover. If you test them through a web browser using a tool like Selenium, then you won't be able to get coverage.

Now I'm wonder if anyone in the silverlight team has tried to use NCover + NUnit? Of course MS has their own unit test framework so in the "business sense" it wouldn't look so good :) But how about just testing whether this works.

answered 2009-09-08T16:17:24.340

Your Answer