【问题标题】:Is it possible to use MSTest V2 with Visual Studio 2017 Test Controller and Test Agent for remotely executing unit tests是否可以将 MSTest V2 与 Visual Studio 2017 测试控制器和测试代理一起用于远程执行单元测试
【发布时间】:2018-05-06 12:25:35
【问题描述】:

目标

我希望能够在另一台机器上远程运行我的单元测试,因为它们与另一个应用程序的 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.

我希望我只是缺少一些可以放入我的 .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>

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

【问题讨论】:

    标签: visual-studio-2017 mstest


    【解决方案1】:

    我在 mstest github 页面上打开了一个 issue,在查看了生成我的警告的源代码后,我发现它看起来可能没有解决方法。这是我在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 提供远程执行功能。您可以在支持在多个代理上分布式执行的 VSTS 中使用测试任务。 https://docs.microsoft.com/en-us/vsts/pipelines/test/set-up-continuous-test-environments-builds?view=vsts

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-01-19
      • 2017-08-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-09-09
      • 1970-01-01
      相关资源
      最近更新 更多