是否有可能获取代码覆盖数据使用Visual Studio集成测试? [英] Is it possible to get code coverage data for integration tests using Visual Studio?

查看:148
本文介绍了是否有可能获取代码覆盖数据使用Visual Studio集成测试?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我测试一个ASP.NET应用程序,并希望得到多少的产品代码我的集成测试演习的代码覆盖率信息。我们的图书馆已经仪表和符号(PDB)文件都可以,但我需要知道如何使Visual Studio中捕捉到IIS中执行代码,并返回.coverage文件。我的集成测试是网页API测试和硒的浏览器测试的混合。

I am testing a ASP.NET application and would like to get code coverage information about how much of the product code my integration tests exercise. Our libraries are already instrumented and the symbols (pdb) files are available, but I need to know exactly how to enable Visual Studio to capture the code executing within IIS and return the .coverage file. My integration tests are a mix of web api tests and Selenium browser tests.

可以这样做?

推荐答案

是的,你可以做这种使用动态代码覆盖工具,与Visual Studio 2013年我使用的是高级出货,所以我不能肯定哪个版本可能会或可能不会有这样的组件说。

Yes, you can do this using the Dynamic Code Coverage tools that ship with Visual Studio 2013. I'm using Premium, so I can't say for sure which versions may or may not have this component.

该命令启动覆盖和把它挂到IIS如下:

The command to start coverage and hook it into IIS is as follows:

<VisualStudioInstallDirectory>\Team Tools\Dynamic Code Coverage Tools\CodeCoverage.exe collect /IIS /session:WebSession /output:<CoverageOutputFileName>.coverage

这将重新启动IIS,并启动了覆盖过程。

This will restart IIS and start up the coverage process.

运行的集成测试(或者,如果你想手工做的测试)。完成后,停止使用以下命令覆盖工具:

Run your integration tests (or do manual testing if you want). When finished, stop the coverage tool with the following command:

<VisualStudioInstallDirectory>\Team Tools\Dynamic Code Coverage Tools\CodeCoverage.exe shutdown /session:WebSession 

这将完成创建覆盖文件,然后可以在Visual Studio中打开。请注意,shutdown命令离开CodeCoverage.exe运行。 。重新启动IIS将关闭CodeCoverage.exe流程

This will complete creating the coverage file which can then be opened in Visual Studio. Note, that the shutdown command leaves the CodeCoverage.exe running. Restarting IIS will shut down CodeCoverage.exe processes.

其他一些注意事项:


  • 如果指定的输出覆盖文件已经存在,代码
    覆盖显示器将无法启动。确保使用唯一的文件名或启动之前删除任何现有的文件。

  • 如果您嵌入这些命令在Visual Studio中的外部工具,你
    需要启动Visual Studio中以管理员身份得到它正常启动

  • 如果您想将覆盖文件转换为XML,以便它可以被其他工具消费(如的 https://github.com/danielpalme / ReportGenerator相对=nofollow> ReportGenerator ),你可以用
    以下命令来覆盖转换文件:

  • If the specified output coverage file already exists, the code coverage monitor will not start. Make sure to use unique filenames or delete any existing files before starting.
  • If you embed these commands as External Tools in Visual Studio, you need to launch Visual Studio as Administrator to get it to start correctly.
  • If you want to convert your coverage file to xml so that it can be consumed by other tools (such as ReportGenerator), you can use the following command to convert the coverage file:

\Team Tools\Dynamic代码覆盖分析Tools\CodeCoverage.exe InputCoverageFile.coverage /output:OutputFile.coveragexml

\Team Tools\Dynamic Code Coverage Tools\CodeCoverage.exe analyze InputCoverageFile.coverage /output:OutputFile.coveragexml

这篇关于是否有可能获取代码覆盖数据使用Visual Studio集成测试?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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