简体   繁体   中英

Visual Studio 2012 - code coverage - how to do it correctly?

I'm trying to automate code coverage with unit test. What I have done is:

  1. Created Metro application with some features.

  2. Created Unit Test Library (for Metro app) - in the same solution like my application (above).

  3. Added one test class which contains few test methods.

  4. To be able to compile test library I added link to class created in my application (Add->Existing item->Add as link".

  5. Ran tests under VS - successfully.

  6. Ran tests from console using vstest.console.exe - successfully.

Now I have to calculate code coverage for my application. I knwo that vstest.console.exe has an option to enable code coverage but I use Express version of VS and that feature seems to be not available there.

The question is: How to use vstest.console.exe (or any other tool) to get right code coverage. The tool takes appx of test library project so it calculates coverage for code from the library (mentioned single class from the application), right? How tu use the tool to takes both library with test code and application with all code?

Code coverage is available in premium and ultimate flavors of Visual Studio 2012

However please do note that we have not yet enabled code coverage for Windows Store apps as yet in VS 2012.

We use a tool OpenCover to perform the code coverage. This outputs an xml coverage report of the results. We then pass that xml file to ReportGenerator to create a nicely styled html report.

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