【问题标题】:use visual studio code coverage as external tool使用 Visual Studio 代码覆盖率作为外部工具
【发布时间】:2013-12-21 16:15:11
【问题描述】:

我想利用 Visual Studio 之外的 Visual Studio 代码覆盖能力作为没有 Visual Studio 实例的环境的诊断测试。

我无法获取有关如何完成的教程或指南。 那么怎么做呢? 甚至指导方针也很好。

【问题讨论】:

  • 哪个 Visual Studio 版本?
  • 目前使用 2012 年,不久将移至 2013 年。

标签: visual-studio code-coverage


【解决方案1】:

在 Visual Studio 2012 或更高版本中,您可以使用 vstest.console.exe 调用测试以收集代码覆盖率。 /enableCodeCoverage commandline switch 启用它。

您也可以使用旧的vsperfcmd 工具从命令行收集覆盖范围。这要求您在计算机上至少安装一个 Visual Studio 测试代理。这不是完整的 Visual Studio 安装,但它包含运行测试和收集覆盖率详细信息所需的组件。

How to setup the VsPerfCmd tool can be found here in this MSDN post。我复制了步骤:

我假设您希望 MyApp.exe 上的代码覆盖率

  1. 打开 Visual Studio 命令提示符

  2. 在路径中添加%ProgramFiles%\Microsoft Visual Studio 10\Team Tools\Performance Tools

    set path=%path%;'%ProgramFiles%\Microsoft Visual Studio 10\Team Tools\Performance Tools'

  3. CD 到包含 MyApp.exe 的文件夹

  4. 检测 MyApp.exe 以进行覆盖:

    vsinstr -coverage MyApp.exe

  5. 启动覆盖率监视器收集代码覆盖率数据:

    vsperfcmd -start:coverage -output:MyApp.coverage

  6. 运行检测的 MyApp.exe:

    MyApp.exe

  7. MyApp.exe 完成后关闭显示器:

    vsperfcmd -shutdown

  8. 在 Visual Studio 中打开 MyApp.coverage 文件

使用Test Agent installed on the machine, you can also trigger a test run from Visual Studio(即使它安装在不同的机器上)。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-08-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-01-25
    • 2010-12-15
    相关资源
    最近更新 更多