Ever wondered why Code coverage shows not enabled for the code

1.Creating a test class for your project

Create a test class only when you have completed your coding bc the test class are created based
on your business logic..hence if you add/remove any functions there it wont be reflected in your test
class.

a.Go to Test->New Test in VS.Select Unit test Wizard and give it a appropriate name.All the test
functions wil be autogenerated for you.

b.Right click on solution and select add new file.Select Test Run Configuration in the general tab.

This file will end with .testrunconfig wherein you can specify different rules for your test to run.

If you want to check how much coverage you have achieved open this file and select Code Coverage-

Check the files for which you want to see the coverage.

c.Check if a .vsmdi file is created . if not then goto Test->Select Active Test Run configuration and
select the file you want to associate.

You can have many .testrunconfig files and associate them to a .vsmdi file which will be picked up by
you test class.

c. After writing all the test class select test->Run->All Test in solution. Remember to run test rather
then just clicking F5

d.Click on test->Windows->Code coverage Results.

You can see the code coverage only if all your test case are passed.

No comments:

Post a Comment