0

我已经下载了 Visual Studio 2019 和 Coded UI 组件,目前正在尝试运行 Web 浏览器自动化测试。测试工作正常,但我创建的 test.runsettings 文件通过测试 > 测试设置附加到 CodedUITest 并将下面的文件应用于测试,但我设置的最大超时值被忽略并且测试正在计时默认 30 分钟后退出

运行设置文件如下:

<?xml version="1.0" encoding="utf-8"?>
<RunSettings>
<!-- Configurations that affect the Test Framework -->
<RunConfiguration>
<MaxCpuCount>1</MaxCpuCount>
<!-- Path relative to directory that contains .runsettings file-->
<ResultsDirectory>.\TestResults</ResultsDirectory>

<!-- x86 or x64 -->
<!-- You can also change it from the top-level menu Test > Test Settings > Processor Architecture for AnyCPU Projects -->
<TargetPlatform>x86</TargetPlatform>

<!-- Framework35 | [Framework40] | Framework45 -->
<TargetFrameworkVersion>Framework45</TargetFrameworkVersion>

<!-- Path to Test Adapters -->

<TestAdaptersPaths>%SystemDrive%\Temp\foo;</TestAdaptersPaths>


<!-- TestSessionTimeout was introduced in Visual Studio 2017 version 15.5 -->
<!-- Specify timeout in milliseconds. A valid value should be greater than 0 -->
<TestSessionTimeout>99999999</TestSessionTimeout>
</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>

  <DataCollector uri="datacollector://microsoft/VideoRecorder/1.0" assemblyQualifiedName="Microsoft.VisualStudio.TestTools.DataCollection.VideoRecorder.VideoRecorderDataCollector, Microsoft.VisualStudio.TestTools.DataCollection.VideoRecorder, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" friendlyName="Screen and Voice Recorder">
    <!--Video data collector was introduced in Visual Studio 2017 version 15.5 -->
  </DataCollector>

</DataCollectors>
</DataCollectionRunSettings>

<!-- Parameters used by tests at runtime -->
<TestRunParameters>
<Parameter name="webAppUrl" value="http://localhost" />
<Parameter name="webAppUserName" value="Admin" />
<Parameter name="webAppPassword" value="Password" />
</TestRunParameters>

<!-- Adapter Specific sections -->

<!-- MSTest adapter -->
<MSTest>
  <MapInconclusiveToFailed>True</MapInconclusiveToFailed>
<CaptureTraceOutput>false</CaptureTraceOutput>
<DeleteDeploymentDirectoryAfterTestRunIsComplete>False</DeleteDeploymentDirectoryAfterTestRunIsComplete>
<DeploymentEnabled>False</DeploymentEnabled>
<AssemblyResolution>
  <Directory path="D:\myfolder\bin\" includeSubDirectories="false"/>
</AssemblyResolution>
</MSTest>

</RunSettings>
4

1 回答 1

0

我遇到了同样的问题。对于编码的 UI 测试,请在测试方法中使用 timeout 属性

[Timeout(milliseconds)]
public void DemoTest()
{
}

如果你想要无限执行超时,你可以使用下面的代码

[Timeout(TestTimeout.Infinite)]
public void DemoTest()
{
}

希望这可以帮助

于 2019-08-21T10:59:35.037 回答