.runsettings和代码覆盖率 [英] .runsettings and code coverage
问题描述
您好,
VS 2015 entreprise。版本14.0.25431.01更新3.
$
使用.runsettings,是否有人知道如何为测试后生成的.coverage指定名称?
确实,它有一个丑陋的名字,我只想在data.coverage中将其重命名为.localsettings。
我正在使用vstest .console.exe。
同样,当我使用MSTest.exe时,它用于生成"In"。文件夹和"Out"文件夹,并复制所有二进制文件。
mstest.console.exe只生成一个In文件夹,没有包含二进制文件的Out文件夹。
需要帮助这是我的.runsettings:
<?xml version =" 1.0" encoding =" utf-8"?>
< RunSettings>
<! - 影响测试框架的配置 - >
< RunConfiguration>
< MaxCpuCount> 4< / MaxCpuCount>
<! - 相对于解决方案目录的路径 - >
< ResultsDirectory> .\TestResults< / ResultsDirectory>
<! - [x86] | x64
- 您也可以从菜单测试,测试设置,默认处理器架构中更改它 - >
< TargetPlatform> x86< / TargetPlatform>
<! - Framework35 | [Framework40] | Framework45 - >
< TargetFrameworkVersion> Framework45< / TargetFrameworkVersion>
< / RunConfiguration>
<! - 数据收集器的配置 - >
< DataCollectionRunSettings>
< DataCollectors>
< DataCollector friendlyName =" Code Coverage" URI = QUOT; datacollector://Microsoft/CodeCoverage/2.0" assemblyQualifiedName =" Microsoft.VisualStudio.Coverage.DynamicCoverageDataCollector,Microsoft.VisualStudio.TraceCollector,
Version = 11.0.0.0,Culture = neutral,PublicKeyToken = b03f5f7f11d50a3a">
&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; <配置>
< CodeCoverage>
< ModulePaths>
< Include>&
< ModulePath> *****。exe< / ModulePath>
< / Include>&
< / ModulePaths>&
<! - 我们建议您不要更改以下值: - >
< UseVerifiableInstrumentation> True< / UseVerifiableInstrumentation>
< AllowLowIntegrityProcesses> True< / AllowLowIntegrityProcesses>
< CollectFromChildProcesses> True< / CollectFromChildProcesses>
< CollectAspDotNet> False< / CollectAspDotNet>
< / CodeCoverage>
< / Configuration>
< / DataCollector>
< / DataCollectors>
< / DataCollectionRunSettings>
< / RunSettings>
谢谢。
Gantz
嗨Gantz,
VStest 和 MStest 不支持
设置或 testsettings 选项的任何参数,覆盖文件名的格式总是如下:
{username} _ {workstation} {timestamp} .coverage ,到目前为止,无论是由Visual Studio还是命令行生成,都无法指定它。
如果可以在特定目录中创建覆盖文件,则有一种解决方法:
- 创建新的临时文件夹
- 将当前目录更改为
- 运行测试运行器
- 扫描文件夹以获取结果 coverage 文件使用你最喜欢的递归文件搜索方法,就是这样。
by usin g MSBuild脚本:
例如:
< ItemGroup>
< TestResult Include =" ** \ * .coverage" />
< / ItemGroup>
你可以全部收集<当前目录下的strong> .coverage 文件,并将其填入
@(TestResult)项目组进行进一步处理。
我希望它有用。
祝你好运,
Fletch
Hello,
VS 2015 entreprise. Version 14.0.25431.01 Update 3.
With .runsettings, does anybody know how you can specify a name for the .coverage generated after tests ?
Indeed, it has an ugly name, and I just would like to rename it like with .localsettings, in data.coverage.
I'm using vstest.console.exe.
And as well, when I used MSTest.exe it used to generate a "In" folder, and an "Out" folder, and copy all binaries inside.
mstest.console.exe only generates a In folder, and no Out folder with binaries.
NEED HELP !
Here is my .runsettings:
<?xml version="1.0" encoding="utf-8"?>
<RunSettings>
<!-- Configurations that affect the Test Framework -->
<RunConfiguration>
<MaxCpuCount>4</MaxCpuCount>
<!-- Path relative to solution directory -->
<ResultsDirectory>.\TestResults</ResultsDirectory>
<!-- [x86] | x64
- You can also change it from menu Test, Test Settings, Default Processor Architecture -->
<TargetPlatform>x86</TargetPlatform>
<!-- Framework35 | [Framework40] | Framework45 -->
<TargetFrameworkVersion>Framework45</TargetFrameworkVersion>
</RunConfiguration>
<!-- Configurations for data collectors -->
<DataCollectionRunSettings>
<DataCollectors>
<DataCollector friendlyName="Code Coverage" uri="datacollector://Microsoft/CodeCoverage/2.0" assemblyQualifiedName="Microsoft.VisualStudio.Coverage.DynamicCoverageDataCollector, Microsoft.VisualStudio.TraceCollector,
Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<Configuration>
<CodeCoverage>
<ModulePaths>
<Include>
<ModulePath>*****.exe</ModulePath>
</Include>
</ModulePaths>
<!-- We recommend you do not change the following values: -->
<UseVerifiableInstrumentation>True</UseVerifiableInstrumentation>
<AllowLowIntegrityProcesses>True</AllowLowIntegrityProcesses>
<CollectFromChildProcesses>True</CollectFromChildProcesses>
<CollectAspDotNet>False</CollectAspDotNet>
</CodeCoverage>
</Configuration>
</DataCollector>
</DataCollectors>
</DataCollectionRunSettings>
</RunSettings>
Thanks.
Gantz
Hi Gantz,
VStest and MStest do not support any parameters for settings or testsettings option, format of the coverage file name is always like: {username}_{workstation} {timestamp}.coverage, so far there is not possible to specify it, no matter generated by Visual Studio or command line.
If the coverage file could be created in a particular directory, then there is a workaround:
- Create a new temporary folder
- Change the current directory to it
- Run the test runner
- Scan the folder for the result coverage file using your favorite recursive file search method and that’s it.
By using MSBuild script:
Eg:
<ItemGroup>
<TestResult Include="**\*.coverage"/>
</ItemGroup>
You could Collect all .coverage file under the current directory and stuff them into the @(TestResult) item group for further processing.
I hope it’s helpful.
Best regards,
Fletch
这篇关于.runsettings和代码覆盖率的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!