Unit testing TFS 2015和x64单元测试
我将TFS 2015与CI一起使用,在成功构建x64之后,单元测试也应该在x64中运行。但是,它们在x86中运行,这导致大多数测试失败 要为x64构建,将$(BuildPlatform)变量设置为x64就足够了,但对于测试来说,这没有任何效果 我得到的测试输出如下:Unit testing TFS 2015和x64单元测试,unit-testing,tfs,visual-studio-2015,continuous-integration,64-bit,Unit Testing,Tfs,Visual Studio 2015,Continuous Integration,64 Bit,我将TFS 2015与CI一起使用,在成功构建x64之后,单元测试也应该在x64中运行。但是,它们在x86中运行,这导致大多数测试失败 要为x64构建,将$(BuildPlatform)变量设置为x64就足够了,但对于测试来说,这没有任何效果 我得到的测试输出如下: 2016-05-03T06:42:38.7749398Z Microsoft(R)测试执行命令行工具版本14.0.25123.0 2016-05-03T06:42:38.7749398Z版权所有(c)微软公司。版权所有。 2016-
2016-05-03T06:42:38.7749398Z Microsoft(R)测试执行命令行工具版本14.0.25123.0
2016-05-03T06:42:38.7749398Z版权所有(c)微软公司。版权所有。
2016-05-03T06:42:38.9155623Z开始执行测试,请稍候。。。
2016-05-03T06:42:39.4155556Z测试运行将使用为框架45和平台X86构建的DLL。以下DLL将不是运行的一部分:…
要让TFS使用x64进行测试,我必须做什么
谢谢你的帮助 找到了答案:
您需要指定x64的test.runsettings文件
<?xml version="1.0" encoding="utf-8"?>
<!-- File name extension must be .runsettings -->
<RunSettings>
<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>x64</TargetPlatform>
<!-- Framework35 | [Framework40] | Framework45 -->
<TargetFrameworkVersion>Framework45</TargetFrameworkVersion>
</RunConfiguration>
<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>.*\.dll$</ModulePath>
</Include>
<Exclude>
<ModulePath>.*CPPUnitTestFramework.*</ModulePath>
</Exclude>
</ModulePaths>
<Attributes>
<Exclude>
<!-- Don’t forget "Attribute" at the end of the name -->
<Attribute>^System.Diagnostics.DebuggerHiddenAttribute$</Attribute>
<Attribute>^System.Diagnostics.DebuggerNonUserCodeAttribute$</Attribute>
<Attribute>^System.Runtime.CompilerServices.CompilerGeneratedAttribute$</Attribute>
<Attribute>^System.CodeDom.Compiler.GeneratedCodeAttribute$</Attribute>
<Attribute>^System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverageAttribute$</Attribute>
</Exclude>
</Attributes>
<UseVerifiableInstrumentation>True</UseVerifiableInstrumentation>
<AllowLowIntegrityProcesses>True</AllowLowIntegrityProcesses>
<CollectFromChildProcesses>True</CollectFromChildProcesses>
<CollectAspDotNet>False</CollectAspDotNet>
</CodeCoverage>
</Configuration>
</DataCollector>
</DataCollectors>
</DataCollectionRunSettings>
</RunSettings>
4.
测试结果
x64
框架45
.\.dll$
*CPPUnitTestFramework*
^System.Diagnostics.DebuggerHiddenAttribute$
^System.Diagnostics.DebuggerNonUserCodeAttribute$
^System.Runtime.CompilerServices.CompilerGeneratedAttribute$
^System.CodeDom.Compiler.GeneratedCodeAttribute$
^System.Diagnostics.CodeAnalysis.ExcludeFromCodeOverageAttribute$
真的
真的
真的
假的
除此之外,您的项目应该使用相同版本的.Net