简体   繁体   中英

Visual Studio 2010 - MSTest and code coverage analysis unusual behavior

I have a Visual Studio 2010 C# solution using MSTest for unit testing. Code coverage analysis is enabled and has been working without any issues until now.

Within the last few days, the code coverage analysis report has been returning strange results. For example, I have classes A, B, C and D. Classes A, B and C all have unit tests, but D does not. When unit testing is run, all unit tests are shown to have run and passed. I can look at individual tests and see they run. However, the code coverage report will not show class A at all, class B will have 50% coverage when it is actually 100% covered, class C will be correct and somehow class D will have 25% coverage, even though there are no unit tests for it. Percentages are for example purposes.

I've cleaned and rebuilt, deleted the bin and obj folders entirely, downloaded the code from Subversion into a fresh folder, etc., etc. Google is not giving me help on this.

I realise this is an old question, but it may help inexperienced developers.

It is possible that class A calls code in class D, which is run as part of the tests for class A. This then creates a bit of coverage in class D.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM