是否可以将MSTest V2与Visual Studio 2017测试控制器和测试代理一起用于远程执行单元测试

Max*_*ung 6 mstest visual-studio-2017

目标

我希望能够在另一台机器上远程运行我的单元测试,因为它们与另一台应用程序的UI交互.为清楚起见,这些测试不是编码UI测试,它们是使用FlaUI与桌面交互的测试方法.

问题

我无法让Visual Studio测试控制器和测试代理与MSTest V2一起使用.当我将.runsettings文件设置为使用该.testsettings文件并且ForcedLegacyMode喜欢此处的文档时,我收到以下警告,并且没有测试加载到测试资源管理器中.

[11/22/2017 9:54:12 AM Warning] Index was outside the bounds of the array.
[11/22/2017 9:54:13 AM Warning] Index was outside the bounds of the array.
[11/22/2017 9:54:13 AM Warning] Index was outside the bounds of the array.
[11/22/2017 9:54:14 AM Warning] Warning : A testsettings file or a runsettings with a ForcedLegacyMode set to true is not supported with the MSTest V2 Adapter.
Run Code Online (Sandbox Code Playgroud)

我希望我只是缺少一些设置,我可以放入我的.runsettings文件,这将允许我指定我的测试控制器的URL.

设置

这是我的.runsettings.testsettings文件供参考.这些设置成功连接到机器,但是当我构建我的测试运行器时,不再查找并运行测试.

.runSettings

  <?xml version="1.0" encoding="utf-8"?>
  <RunSettings>
    <!-- Configurations that affect the Test Framework -->
    <RunConfiguration>
      <MaxCpuCount>1</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>Framework40</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>
                <Exclude>
                  <ModulePath>.*CPPUnitTestFramework.*</ModulePath>
                </Exclude>
              </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>

    <!-- Parameters used by tests at runtime -->
    <TestRunParameters>
    </TestRunParameters>

    <!-- Adapter Specific sections -->

    <!-- MSTest adapter -->
    <MSTest>
      <MapInconclusiveToFailed>True</MapInconclusiveToFailed>
      <CaptureTraceOutput>false</CaptureTraceOutput>
      <DeleteDeploymentDirectoryAfterTestRunIsComplete>False</DeleteDeploymentDirectoryAfterTestRunIsComplete>
      <DeploymentEnabled>False</DeploymentEnabled>
    </MSTest>

  </RunSettings>
Run Code Online (Sandbox Code Playgroud)

.testsettings

<?xml version="1.0" encoding="UTF-8"?>
<TestSettings name="rmoqa01" id="076be28c-d18b-46bf-ad20-4d43ec821ea4" xmlns="http://microsoft.com/schemas/VisualStudio/TeamTest/2010">
  <Description>These are default test settings for a local test run.</Description>
  <RemoteController name="10.2.0.101" />
  <Execution location="Remote">
    <Hosts skipUnhostableTests="false">
      <VSSDKTestHostRunConfig name="VS IDE" HiveKind="DevEnv" HiveName="15.0_c9b36733" xmlns="http://microsoft.com/schemas/VisualStudio/SDK/Tools/IdeHostAdapter/2006/06" />
    </Hosts>
    <TestTypeSpecific>
      <UnitTestRunConfig testTypeId="13cdc9d9-ddb5-4fa4-a97d-d965ccfc6d4b">
        <AssemblyResolution>
          <TestDirectory useLoadContext="true" />
        </AssemblyResolution>
      </UnitTestRunConfig>
    </TestTypeSpecific>
    <AgentRule name="AllAgentsDefaultRole">
    </AgentRule>
  </Execution>
  <Properties />
</TestSettings>
Run Code Online (Sandbox Code Playgroud)

Max*_*ung 2

我在 mstest github 页面上打开了一个问题,在查看生成警告的源代码后,我发现似乎没有解决此问题的方法。这是我在MSTestDiscover.cs中查看的源代码。

    // Scenarios that include testsettings or forcing a run via the legacy adapter are currently not supported in MSTestAdapter.
    if (MSTestSettings.IsLegacyScenario(logger))
    {
        return;
    }
Run Code Online (Sandbox Code Playgroud)

编辑:2018 年 10 月 28 日

我上面链接的问题已更新为以下响应

没有计划通过 MSTVest2 提供远程执行功能。您可以使用VSTS中的测试任务,它支持在多个代理上分布式执行。https://learn.microsoft.com/en-us/vsts/pipelines/test/set-up-continuous-test-environments-builds?view=vsts