【问题标题】:How to make MSTest to run tests in parallel using the command prompt如何使 MSTest 使用命令提示符并行运行测试
【发布时间】:2015-09-18 21:34:28
【问题描述】:

我正在使用 MSTest.exe 工具来使用命令提示符(在 powershell 脚本中)运行我的集成测试。

但我发现它运行得非常慢,我需要更快地运行它。 查看 powershell 输出,MSTest 似乎实际上是一个一个地运行它们。

有没有办法一起或并行运行它们?

我正在使用此命令运行测试:

MSTest.exe "/testcontainer:C:\myTestClass.dll" "/resultsfile:C:\TestResult.trx" 

【问题讨论】:

    标签: automated-tests integration-testing mstest


    【解决方案1】:

    您可以为此使用测试设置。

    在您的测试 dll 所在的同一文件夹中添加一个 .testsettings 文件。

    您的 .testsettings 文件应如下所示(注意 Execution 元素上的“parallelTestCount”属性):

    <TestSettings name="SecurityWebApi" id="5f0defa1-d6a5-40a6-94ae-1522a7aeeba8" xmlns="http://microsoft.com/schemas/VisualStudio/TeamTest/2010">
      <Description>These are default test settings for a local test run.</Description>
      <Execution parallelTestCount="5">
        <TestTypeSpecific>
          <UnitTestRunConfig testTypeId="13cdc9d9-dd`enter code here`b5-4fa4-a97d-d965ccfc6d4b">
            <AssemblyResolution>
              <TestDirectory useLoadContext="true" />
            </AssemblyResolution>
          </UnitTestRunConfig>
          <WebTestRunConfiguration testTypeId="4e7599fa-5ecb-43e9-a887-cd63cf72d207">
            <Browser name="Internet Explorer 7.0">
              <Headers>
                <Header name="User-Agent" value="Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)" />
                <Header name="Accept" value="*/*" />
                <Header name="Accept-Language" value="{{$IEAcceptLanguage}}" />
                <Header name="Accept-Encoding" value="GZIP" />
              </Headers>
            </Browser>
          </WebTestRunConfiguration>
        </TestTypeSpecific>
        <AgentRule name="LocalMachineDefaultRole">
        </AgentRule>
      </Execution>
      <Properties />
    </TestSettings>
    

    然后在你的命令中你可以像这样使用它:

    MSTest.exe "/testcontainer:C:\myTestClass.dll" "/runsettings:yourfile.runsettings" "/resultsfile:C:\TestResult.trx"
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-04-24
      • 1970-01-01
      • 2012-01-13
      • 2013-03-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多