Does VS2010 Code Coverage support nUnit?

后端 未结 9 1988
情深已故
情深已故 2020-12-25 12:35

According to this schema VS2010 Premium and Ultimate has a tool for checking Code Coverage - together with a few other testing tools. Does this support nUnit too, or just MS

9条回答
  •  余生分开走
    2020-12-25 13:18

    It's doable, but requires a bit of setup. I just got it working with xUnit. Presumably the below will work with NUnit too.

    For this to work, you'll need three projects

    • The System Under Test -- SUT
    • A testing project using your favorite unit testing framework -- xUnitTest
    • A VS Test Project -- VSTest

      1. Create the VSTest project (breath easy)
      2. Delete the default UnitTest1.cs file
      3. Add a "Generic Test" to VSTest
      4. Specify the full path to the win32 version of the console runner for your testing framework, such as xunit.console.x86.exe
      5. Specify the full path to the xUnitTest dll
      6. Under the VS Test Menu->Edit Test Settings->Local->
      7. Data & Diagnostics "Tab"
      8. Make sure only Code Coverage is enabled
      9. Select Code Coverage row, then click the "Configure" button above (yes, this is a well designed UI :)
      10. In the "Code Coverage Detail" dialog
      11. Select both the dlls for SUT and xUnitTest
      12. Enable "Instrument assemblies in test"

    Now when you run the VS2010 test, it'll correctly instrument the test dlls, run the code runner and gather the info into Visual Studio.

提交回复
热议问题