如何防止TFS移动vstest.console runsettings文件

时间:2017-02-02 11:42:21

标签: tfs tfs2017

我正在测试从TFS2015到TFS2017的升级,并在运行我的单元测试时遇到问题。

测试需要一个runsettings文件:

enter image description here

runsettings文件实际上位于C:\TFS\1\s但由于某种原因,TFS2017正在将其复制到C:\Windows\ServiceProfiles\NetworkService\AppData\Local\Temp\tmpA03,如日志中所示:

2017-02-01T21:04:44.9728814Z Working folder: C:\TFS\1\s
2017-02-01T21:04:44.9728814Z Executing C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe "C:\TFS\1\s\SpecFlow2\bin\Debug\SpecFlowTests.dll" "C:\TFS\1\s\UnitTests\bin\Debug\UnitTests.dll" "C:\TFS\1\s\UnitTests-Analytics\bin\Debug\UnitTests-Analytics.dll"  /TestCaseFilter:"TestCategory!=MultiThreadedTests&TestCategory!=Purgatory" /Settings:"C:\Windows\ServiceProfiles\NetworkService\AppData\Local\Temp\tmpA03.tmp" /logger:trx

然而,我的runsettings包含对testsettings的引用:

<?xml version="1.0" encoding="utf-8"?>
<RunSettings>
  <RunConfiguration>
    <!-- 0 = As many processes as possible, limited by number of cores on machine, 1 = Sequential (1 process), 2-> Given number of processes up to limit by number of cores on machine-->
    <ResultsDirectory>.\TestResults</ResultsDirectory>
    <MaxCpuCount>3</MaxCpuCount>
    <TargetPlatform>x64</TargetPlatform>
  </RunConfiguration>

  <MSTest>
    <SettingsFile>SingleThreaded.testsettings</SettingsFile>
    <ForcedLegacyMode>true</ForcedLegacyMode>
  </MSTest>
</RunSettings>

由于SingleThreaded.testsettings仍在C:\TFS\1\s中,测试运行失败,即使我手动复制文件,测试仍然失败,因为某些测试依赖于测试的工作目录

如何阻止TFS将我的runsettings文件移动到临时文件夹并从正确的目录执行?

1 个答案:

答案 0 :(得分:1)

我无法通过以下设置在TFS 2017中重现您的问题:

enter image description here

在日志中,runsetting文件来自C:\Agent\_work\10\s\Parallel.runsettings,因此TFS不会自动移动设置文件:

2017-02-03T06:08:37.8352139Z Working folder: C:\Agent\_work\10\s
2017-02-03T06:08:37.8352139Z Executing C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe "C:\Agent\_work\10\s\ClassLibrary1\bin\Release\Microsoft.TeamFoundation.TestManagement.Client.dll" "C:\Agent\_work\10\s\TestCaseProject\bin\Release\Microsoft.TeamFoundation.Test.WebApi.dll" "C:\Agent\_work\10\s\TestCaseProject\bin\Release\Microsoft.TeamFoundation.TestManagement.Client.dll" "C:\Agent\_work\10\s\TestCaseProject\bin\Release\Microsoft.TeamFoundation.TestManagement.WebApi.dll" "C:\Agent\_work\10\s\UnitTestProject1\bin\Release\Microsoft.TeamFoundation.TestManagement.Client.dll" "C:\Agent\_work\10\s\UnitTestProject1\bin\Release\UnitTestProject1.dll"  /Settings:"C:\Agent\_work\10\s\Parallel.runsettings" /logger:trx

请检查您是否已在构建定义的Repository选项卡中映射了runsetting文件。并尝试清除构建代理上的缓存文件:C:\Users\username\AppData\Local\Microsoft\Team Foundation\7.0\Cache

如果问题仍然存在,请尝试部署新的构建代理以查看其工作原理。