简体   繁体   中英

How to run code-coverage from the command line with NUnit 2.6

I use Visual Studio 2015 with NUnit 2.6, and I'm able to run my unit tests from the UI and see the code coverage in Visual Studio. -- My solution has about 10 projects in it.

I'd like to be able to script this process and invoke it from the command line, but when I'm looking through the NUnit command line arguments, I'm not seeing anything related to code coverage. And the documentation is not appearing to be very friendly here.

What specific command-line arguments should I use to run all of the NUnit unit tests in my solution, from the command line, and have it report a code coverage number (preferably in an output file that's in a machine readable format -- such as XML or JSON)?

Below is a part of the script that execute the nunit test via a command prompt.

mkdir %cd%\TestResults   
"E:\tools\NUnit-3.2.1\bin\nunit3-console.exe" ".\path\to\the assembly file some.dll" "--result:.\TestResults\TestResult.xml;format=nunit2"

I am using this in our continuous integration, and there was a compatibility issue (with a downstream step, that processes the data for publishing) so i had to convert the output file into nunit2 format output file.

NOTE: the output file will not include the code coverage stats though. You have to pass this file to a tool like SONARQube to get that stats, IMHO

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