代码之家  ›  专栏  ›  技术社区  ›  Max Young

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

  •  7
  • Max Young  · 技术社区  · 7 年前

    球门

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

    问题

    我无法使Visual Studio测试控制器和测试代理与MSTest V2一起工作。当我设置 .runsettings .testsettings 文件和收件人 ForcedLegacyMode 就像文件上说的那样 here 我收到以下警告,没有测试加载到测试资源管理器中。

    [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.
    

    .运行设置 文件,该文件将允许我指定测试控制器的url。

    设置

    .运行设置 .测试设置 供参考的文件。这些设置已成功连接到计算机,但当我构建测试运行程序时,将不再找到要运行的测试。

    .运行设置

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

    .测试设置

    <?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>
    
    1 回复  |  直到 7 年前
        1
  •  2
  •   Max Young    6 年前

    我打开了一个 issue 在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;
        }
    

    编辑:2018年10月28日

    我上面链接的问题更新如下 response .

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