TFS 2015 with x64 Unit Tests

时间:2016-05-03 07:11:59

标签: unit-testing tfs visual-studio-2015 continuous-integration 64-bit

我使用TFS 2015和CI,在成功构建x64之后,单元测试也应该在x64中运行。但相反,它们在x86中运行,导致大多数测试失败。test configuration

要为x64构建,只需将$(BuildPlatform)变量设置为x64,但对于测试,这不会产生任何影响。

我得到了测试的输出:

2016-05-03T06:42:38.7749398Z Microsoft (R) Test Execution Command Line Tool Version 14.0.25123.0 2016-05-03T06:42:38.7749398Z Copyright (c) Microsoft Corporation. All rights reserved. 2016-05-03T06:42:38.9155623Z Starting test execution, please wait... 2016-05-03T06:42:39.4155556Z Test run will use DLL(s) built for framework Framework45 and platform X86. Following DLL(s) will not be part of run: ...

我需要做什么才能让TFS用x64进行测试?

谢谢你的帮助!

1 个答案:

答案 0 :(得分:6)

找到答案: 您需要一个test.runsettings文件,其中指定了x64。

<?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>