vstest.console.exe工作,但没有一个好的文件名,CodeCoverage.exe不会给出任何结果

时间:2016-04-29 20:55:44

标签: visual-studio visual-studio-2015 code-coverage mstest

我有以下设置:

set __vsTestConsoleExe=C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe
set __codeCoverageExe=C:\Program Files (x86)\Microsoft Visual Studio 14.0\Team Tools\Dynamic Code Coverage Tools\CodeCoverage.exe

set __testFile=My.UnitTests.dll

REM Below I get a ".coverage" file with the correct coverage.  But the file name is kinda-random
"%__vsTestConsoleExe%" "%__testFile%" /InIsolation /EnableCodeCoverage

PAUSE

REM  Below I get a big ole nothing
"%__codeCoverageExe%" collect /output:DynamicCodeCoverage.coverage "%__vsTestConsoleExe%" "%__testFile%" /InIsolation /EnableCodeCoverage 
"%__codeCoverageExe%" analyze /output:DynamicCodeCoverage.coveragexml DynamicCodeCoverage.coverage

当下面一行运行时:

"%__vsTestConsoleExe%" "%__testFile%" /InIsolation /EnableCodeCoverage

我得到了一个很好的.coverage文件,但它生成的文件名如下:

MyUSERNAME_MYMACHINE 2016-03-24 16_03_20.coverage

PAUSE语句后面的行(在第一个代码块中)看起来应该收集覆盖范围(注意,我给它的相同'"%__ vsTestConsoleExe%&#34 ;' comamand .......但是我从中得到了很多。

我做错了什么?

1 个答案:

答案 0 :(得分:0)

我无法让vstest.console.exe工作。

我能够得到一个可预测的"文件名并使用MsTest.exe获取.coverage文件中的信息。

set __msTestExe=C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\MSTest.exe
set __codeCoverageExe=C:\Program Files (x86)\Microsoft Visual Studio 14.0\Team Tools\Dynamic Code Coverage Tools\CodeCoverage.exe



REM the below calls will create the binary *.coverage files
"%__codeCoverageExe%" collect /output:"D:\BuildStuff\TestResults\AAA_DynamicCodeCoverage.coverage" "%__msTestExe%" /testcontainer:"D:\BuildStuff\BuildResults\My.UnitTests.One.dll" /resultsfile:"D:\BuildStuff\TestResults\My.UnitTests.One.trx"
"%__codeCoverageExe%" collect /output:"D:\BuildStuff\TestResults\BBB_DynamicCodeCoverage.coverage" "%__msTestExe%" /testcontainer:"D:\BuildStuff\BuildResults\My.UnitTests.Two.dll" /resultsfile:"D:\BuildStuff\TestResults\My.UnitTests.Two.trx"
"%__codeCoverageExe%" collect /output:"D:\BuildStuff\TestResults\CCC_DynamicCodeCoverage.coverage" "%__msTestExe%" /testcontainer:"D:\BuildStuff\BuildResults\My.UnitTests.Three.dll" /resultsfile:"D:\BuildStuff\TestResults\My.UnitTests.Three.trx"

您还可以将3个UnitTests.dlls组合成一个调用

REM the below calls will create the binary *.coverage file
"%__codeCoverageExe%" collect /output:"D:\BuildStuff\TestResults\ZZZ_DynamicCodeCoverage.coverage" "%__msTestExe%" /testcontainer:"D:\BuildStuff\BuildResults\My.UnitTests.One.dll" /testcontainer:"D:\BuildStuff\BuildResults\My.UnitTests.Two.dll" /testcontainer:"D:\BuildStuff\BuildResults\My.UnitTests.Three.dll" /resultsfile:"D:\BuildStuff\TestResults\My.UnitTests.AllOfThem.trx"

ZZZ_DynamicCodeCoverage.coverage是"可预测" named,并在.coverage文件中包含实际值。

不知道为什么CodeCoverage.exe创建的.coverage文件与其参数列表中的vstest.console.exe ....不起作用。 :( 再说一遍,并不是平等的。 '创建.coverage文件,但打开它,它没有信息"。