[英]Excluding assemblies from code coverage in Visual Studio Team Services
I have a build running on Visual Studio Team Services (formerly Visual Studio Online). 我有一个在Visual Studio Team Services(以前的Visual Studio Online)上运行的构建。 I want to exclude some of the assemblies from code coverage calculations.
我想从代码覆盖率计算中排除一些程序集。 Based on a format I've read from many sources .
基于我从 许多 来源阅读的格式。 I have created a .runsettings file as follows:
我创建了一个.runsettings文件,如下所示:
<?xml version="1.0" encoding="utf-8"?>
<RunSettings>
<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>
<Exclude>
<ModulePath>*AWSSDK*</ModulePath>
</Exclude>
</ModulePaths>
</CodeCoverage>
</Configuration>
</DataCollector>
</DataCollectors>
</DataCollectionRunSettings>
</RunSettings>
But this produces the following error: 但是这会产生以下错误:
Starting test execution, please wait... Error: System.InvalidOperationException: Cannot mix synchronous and asynchronous operation on process stream. 开始测试执行,请稍候...错误:System.InvalidOperationException:无法在进程流上混合同步和异步操作。 at System.Diagnostics.Process.get_StandardError() at Microsoft.VisualStudio.Coverage.Vanguard.Wait() at Microsoft.VisualStudio.Coverage.Vanguard.Start(String outputName, DataCollectionContext context) at Microsoft.VisualStudio.Coverage.DynamicCoverageDataCollectorImpl.StartVanguard(DataCollectionContext context) at Microsoft.VisualStudio.Coverage.UnitTestDataCollector.SessionStart(Object sender, SessionStartEventArgs e) at Microsoft.VisualStudio.Coverage.DynamicCoverageDataCollector.SessionStart(Object sender, SessionStartEventArgs e) at System.EventHandler`1.Invoke(Object sender, TEventArgs e) at WEX.TestExecution.TaefDataCollectionEvents.OnSessionStart(SessionStartEventArgs e) at WEX.TestExecution.DataCollectorTestMode.Initialize(ITestModeSettings settings, ICallbackRegistrar callbackRegistrar) Information: Additionally, you can try specifying '/UseVsixExtensions' command if the test discoverer & executor is installed on the machine as vsix extensions and your installation supports v
在System.Diagnostics.Process.get_StandardError()at Microsoft.VisualStudio.Coverage.Vanguard.Wait()at Microsoft.VisualStudio.Coverage.Vanguard.Start(String outputName,DataCollectionContext context)at Microsoft.VisualStudio.Coverage.DynamicCoverageDataCollectorImpl.StartVanguard( System.EventHandler`1.Invoke(对象发送者,TEventArgs)上的Microsoft.VisualStudio.Coverage.DynamicCoverageDataCollector.SessionStart(Object sender,SessionStartEventArgs e)中的Microsoft.VisualStudio.Coverage.UnitTestDataCollector.SessionStart(Object sender,SessionStartEventArgs e)中的DataCollectionContext上下文) e)WEX.TestExecution.TaefDataCollectionEvents.OnSessionStart(SessionStartEventArgs e)at WEX.TestExecution.DataCollectorTestMode.Initialize(ITestModeSettings settings,ICallbackRegistrar callbackRegistrar)信息:此外,如果安装了测试发现者和执行者,您可以尝试指定'/ UseVsixExtensions'命令在机器上作为vsix扩展,您的安装支持v six extensions.
六个扩展。 Example: vstest.console.exe myTests.dll /UseVsixExtensions:true VSTest Test Run failed with exit code: 1
示例:vstest.console.exe myTests.dll / UseVsixExtensions:true VSTest测试运行失败,退出代码:1
Yes, some of the tests are using async/await. 是的,一些测试使用async / await。 The same .runsettings file works fine in Visual Studio 2015. If I do as it suggests and add the following option:
/UseVsixExtensions:true
, the result is the same. 相同的.runsettings文件在Visual Studio 2015中工作正常。如果我按照建议执行并添加以下选项:
/UseVsixExtensions:true
,结果是相同的。 How can I fix this? 我怎样才能解决这个问题?
The runsettings file use following regex expressions to match the files: runsettings文件使用以下正则表达式来匹配文件:
Regular expressions Include and exclude nodes use regular expressions.
正则表达式包含和排除节点使用正则表达式。 For more information, see Using Regular Expressions in Visual Studio.
有关更多信息,请参见在Visual Studio中使用正则表达式。 Regular expressions are not the same as wildcards.
正则表达式与通配符不同。 In particular:
尤其是:
.* matches a string of any characters
。*匹配任何字符的字符串
.
。 matches a dot ".")
匹配点“。”)
( ) matches parentheses "( )"
()匹配括号“()”
\\ matches a file path delimiter "\\"
\\匹配文件路径分隔符“\\”
^ matches the start of the string
^匹配字符串的开头
$ matches the end of the string
$匹配字符串的结尾
With your original path, all the files will be excluded since you have only "*" in the path. 使用原始路径,将排除所有文件,因为路径中只有“*”。 Refer to this link for details: Regular Expressions in Visual Studio .
有关详细信息,请参阅此链接: Visual Studio中的正则表达式 。
For the bad exception, According to the logs your provided, you are running the build with Hosted Build Agent. 对于错误的异常,根据您提供的日志,您正在使用Hosted Build Agent运行构建。 I did a quick test with Hosted Build Agent and can reproduce this issue too.
我使用Hosted Build Agent进行了快速测试,也可以重现这个问题。 However this issue does not occur when I try with my own build agent.
但是,当我尝试使用自己的构建代理时,不会发生此问题。 I suspect that there is some setting/configuration on Hosted Build Agent cause this issue and I have help your submit a feedback on Microsoft Connect Page.
我怀疑Hosted Build Agent上有一些设置/配置导致此问题,我帮助您在Microsoft Connect页面上提交反馈。 You can check this link for tracking: Invalid exception when run testing from Hosted Build Agent
您可以检查此链接以进行跟踪: 从Hosted Build Agent运行测试时出现无效异常
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.