VS2010代码覆盖率是否支持nUnit? [英] Does VS2010 Code Coverage support nUnit?

查看:61
本文介绍了VS2010代码覆盖率是否支持nUnit?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据此架构 VS2010高级版Ultimate具有一个用于检查代码覆盖率的工具-以及其他一些测试工具.这是否也支持nUnit,或者仅支持MS测试?

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 test?

推荐答案

这是可行的,但需要一点的设置.我刚在xUnit上使用它.大概下面的内容也可以与NUnit一起使用.

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

  • 被测系统- SUT
  • 使用您喜欢的单元测试框架的测试项目- xUnitTest
  • 一个VS测试项目- VSTest

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

  1. 创建 VSTest 项目(轻松完成)
  2. 删除默认的UnitTest1.cs文件
  3. VSTest
  4. 添加通用测试"
  5. 为您的测试框架指定控制台运行程序的win32版本的完整路径,例如xunit.console.x86.exe
  6. 指定 xUnitTest dll
  7. 的完整路径
  8. 在VS测试菜单下->编辑测试设置->本地->
  9. 数据和诊断标签"
  10. 确保启用了代码覆盖率
  11. 选择代码覆盖率"行,然后单击上方的配置"按钮(是的,这是一个设计良好的用户界面:)
  12. 在代码覆盖率详细信息"对话框中
  13. 选择两者用于 SUT xUnitTest
  14. 的dll.
  15. 启用正在测试的仪器组合件"
  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"

现在,当您运行VS2010测试时,它将正确检测测试dll,运行代码运行程序并将信息收集到Visual Studio中.

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.

这篇关于VS2010代码覆盖率是否支持nUnit?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆