VSTest@2 - Visual Studio Test v2 タスク

このタスクを使用して、Visual Studio テスト (VSTest) ランナーを使用して単体テストと機能テスト (Selenium、Appium、コード化された UI テストなど) を実行します。 Visual Studio テスト アダプターを備えたテスト フレームワークを実行できます。 フレームワークの例としては、MSTest、xUnit、NUnit、Chutzpah (QUnit、Mocha、およびジャスミンを使用した JavaScript テスト用) などがあります。テストは、このタスク (バージョン 2) を使用して複数のエージェントに配布できます。

構文

# Visual Studio Test v2
# Run unit and functional tests (Selenium, Appium, Coded UI test, etc.) using the Visual Studio Test (VsTest) runner. Test frameworks that have a Visual Studio test adapter such as MsTest, xUnit, NUnit, Chutzpah (for JavaScript tests using QUnit, Mocha and Jasmine), etc. can be run. Tests can be distributed on multiple agents using this task (version 2).
- task: VSTest@2
  inputs:
  # Test selection
    testSelector: 'testAssemblies' # 'testAssemblies' | 'testPlan' | 'testRun'. Required. Select tests using. Default: testAssemblies.
    testAssemblyVer2: # string. Required when testSelector = testAssemblies. Test files. 
    #testPlan: # string. Required when testSelector = testPlan. Test plan. 
    #testSuite: # string. Required when testSelector = testPlan. Test suite. 
    #testConfiguration: # string. Required when testSelector = testPlan. Test configuration. 
    #tcmTestRun: '$(test.RunId)' # string. Optional. Use when testSelector = testRun. Test Run. Default: $(test.RunId).
    searchFolder: '$(System.DefaultWorkingDirectory)' # string. Required. Search folder. Default: $(System.DefaultWorkingDirectory).
    #resultsFolder: '$(Agent.TempDirectory)\TestResults' # string. Test results folder. Default: $(Agent.TempDirectory)\TestResults.
    #testFiltercriteria: # string. Optional. Use when testSelector = testAssemblies. Test filter criteria. 
    #runOnlyImpactedTests: False # boolean. Optional. Use when testSelector = testAssemblies. Run only impacted tests. Default: False.
    #runAllTestsAfterXBuilds: '50' # string. Optional. Use when testSelector = testAssemblies && runOnlyImpactedTests = true. Number of builds after which all tests should be run. Default: 50.
    #uiTests: false # boolean. Test mix contains UI tests. Default: false.
  # Execution options
    #vstestLocationMethod: 'version' # 'version' | 'location'. Select test platform using. Default: version.
    #vsTestVersion: 'latest' # 'latest' | '17.0' | '16.0' | '15.0' | '14.0' | 'toolsInstaller'. Optional. Use when vstestLocationMethod = version. Test platform version. Default: latest.
    #vstestLocation: # string. Optional. Use when vstestLocationMethod = location. Path to vstest.console.exe. 
    #runSettingsFile: # string. Settings file. 
    #overrideTestrunParameters: # string. Override test run parameters. 
    #pathtoCustomTestAdapters: # string. Path to custom test adapters. 
    #runInParallel: False # boolean. Run tests in parallel on multi-core machines. Default: False.
    #runTestsInIsolation: False # boolean. Run tests in isolation. Default: False.
    #codeCoverageEnabled: False # boolean. Code coverage enabled. Default: False.
    #otherConsoleOptions: # string. Other console options. 
    #diagnosticsEnabled: false # boolean. Collect advanced diagnostics in case of catastrophic failures. Default: false.
    #collectDumpOn: 'onAbortOnly' # 'onAbortOnly' | 'always' | 'never'. Optional. Use when diagnosticsEnabled = true. Collect process dump and attach to test run report. Default: onAbortOnly.
    #rerunFailedTests: False # boolean. Rerun failed tests. Default: False.
    #rerunType: 'basedOnTestFailurePercentage' # 'basedOnTestFailurePercentage' | 'basedOnTestFailureCount'. Optional. Use when rerunFailedTests = true. Do not rerun if test failures exceed specified threshold. Default: basedOnTestFailurePercentage.
    #rerunFailedThreshold: '30' # string. Optional. Use when rerunFailedTests = true && rerunType = basedOnTestFailurePercentage. % failure. Default: 30.
    #rerunFailedTestCasesMaxLimit: '5' # string. Optional. Use when rerunFailedTests = true && rerunType = basedOnTestFailureCount. # of failed tests. Default: 5.
    #rerunMaxAttempts: '3' # string. Optional. Use when rerunFailedTests = true. Maximum # of attempts. Default: 3.
  # Advanced execution options
    #distributionBatchType: 'basedOnTestCases' # 'basedOnTestCases' | 'basedOnExecutionTime' | 'basedOnAssembly'. Batch tests. Default: basedOnTestCases.
    #batchingBasedOnAgentsOption: 'autoBatchSize' # 'autoBatchSize' | 'customBatchSize'. Optional. Use when distributionBatchType = basedOnTestCases. Batch options. Default: autoBatchSize.
    #customBatchSizeValue: '10' # string. Required when distributionBatchType = basedOnTestCases && batchingBasedOnAgentsOption = customBatchSize. Number of tests per batch. Default: 10.
    #batchingBasedOnExecutionTimeOption: 'autoBatchSize' # 'autoBatchSize' | 'customTimeBatchSize'. Optional. Use when distributionBatchType = basedOnExecutionTime. Batch options. Default: autoBatchSize.
    #customRunTimePerBatchValue: '60' # string. Required when distributionBatchType = basedOnExecutionTime && batchingBasedOnExecutionTimeOption = customTimeBatchSize. Running time (sec) per batch. Default: 60.
    #dontDistribute: False # boolean. Replicate tests instead of distributing when multiple agents are used in the job. Default: False.
  # Reporting options
    #testRunTitle: # string. Test run title. 
    #platform: # string. Build platform. 
    #configuration: # string. Build configuration. 
    #publishRunAttachments: true # boolean. Upload test attachments. Default: true.
    #failOnMinTestsNotRun: False # boolean. Fail the task if a minimum number of tests are not run. Default: False.
    #minimumExpectedTests: '1' # string. Optional. Use when failOnMinTestsNotRun = true. Minimum # of tests. Default: 1.
# Visual Studio Test v2
# Run unit and functional tests (Selenium, Appium, Coded UI test, etc.) using the Visual Studio Test (VsTest) runner. Test frameworks that have a Visual Studio test adapter such as MsTest, xUnit, NUnit, Chutzpah (for JavaScript tests using QUnit, Mocha and Jasmine), etc. can be run. Tests can be distributed on multiple agents using this task (version 2).
- task: VSTest@2
  inputs:
  # Test selection
    testSelector: 'testAssemblies' # 'testAssemblies' | 'testPlan' | 'testRun'. Required. Select tests using. Default: testAssemblies.
    testAssemblyVer2: # string. Required when testSelector = testAssemblies. Test files. 
    #testPlan: # string. Required when testSelector = testPlan. Test plan. 
    #testSuite: # string. Required when testSelector = testPlan. Test suite. 
    #testConfiguration: # string. Required when testSelector = testPlan. Test configuration. 
    #tcmTestRun: '$(test.RunId)' # string. Optional. Use when testSelector = testRun. Test Run. Default: $(test.RunId).
    searchFolder: '$(System.DefaultWorkingDirectory)' # string. Required. Search folder. Default: $(System.DefaultWorkingDirectory).
    #resultsFolder: '$(Agent.TempDirectory)\TestResults' # string. Test results folder. Default: $(Agent.TempDirectory)\TestResults.
    #testFiltercriteria: # string. Optional. Use when testSelector = testAssemblies. Test filter criteria. 
    #runOnlyImpactedTests: False # boolean. Optional. Use when testSelector = testAssemblies. Run only impacted tests. Default: False.
    #runAllTestsAfterXBuilds: '50' # string. Optional. Use when testSelector = testAssemblies && runOnlyImpactedTests = true. Number of builds after which all tests should be run. Default: 50.
    #uiTests: false # boolean. Test mix contains UI tests. Default: false.
  # Execution options
    #vstestLocationMethod: 'version' # 'version' | 'location'. Select test platform using. Default: version.
    #vsTestVersion: 'latest' # 'latest' | '16.0' | '15.0' | '14.0' | 'toolsInstaller'. Optional. Use when vstestLocationMethod = version. Test platform version. Default: latest.
    #vstestLocation: # string. Optional. Use when vstestLocationMethod = location. Path to vstest.console.exe. 
    #runSettingsFile: # string. Settings file. 
    #overrideTestrunParameters: # string. Override test run parameters. 
    #pathtoCustomTestAdapters: # string. Path to custom test adapters. 
    #runInParallel: False # boolean. Run tests in parallel on multi-core machines. Default: False.
    #runTestsInIsolation: False # boolean. Run tests in isolation. Default: False.
    #codeCoverageEnabled: False # boolean. Code coverage enabled. Default: False.
    #otherConsoleOptions: # string. Other console options. 
    #diagnosticsEnabled: false # boolean. Collect advanced diagnostics in case of catastrophic failures. Default: false.
    #collectDumpOn: 'onAbortOnly' # 'onAbortOnly' | 'always' | 'never'. Optional. Use when diagnosticsEnabled = true. Collect process dump and attach to test run report. Default: onAbortOnly.
    #rerunFailedTests: False # boolean. Rerun failed tests. Default: False.
    #rerunType: 'basedOnTestFailurePercentage' # 'basedOnTestFailurePercentage' | 'basedOnTestFailureCount'. Optional. Use when rerunFailedTests = true. Do not rerun if test failures exceed specified threshold. Default: basedOnTestFailurePercentage.
    #rerunFailedThreshold: '30' # string. Optional. Use when rerunFailedTests = true && rerunType = basedOnTestFailurePercentage. % failure. Default: 30.
    #rerunFailedTestCasesMaxLimit: '5' # string. Optional. Use when rerunFailedTests = true && rerunType = basedOnTestFailureCount. # of failed tests. Default: 5.
    #rerunMaxAttempts: '3' # string. Optional. Use when rerunFailedTests = true. Maximum # of attempts. Default: 3.
  # Advanced execution options
    #distributionBatchType: 'basedOnTestCases' # 'basedOnTestCases' | 'basedOnExecutionTime' | 'basedOnAssembly'. Batch tests. Default: basedOnTestCases.
    #batchingBasedOnAgentsOption: 'autoBatchSize' # 'autoBatchSize' | 'customBatchSize'. Optional. Use when distributionBatchType = basedOnTestCases. Batch options. Default: autoBatchSize.
    #customBatchSizeValue: '10' # string. Required when distributionBatchType = basedOnTestCases && batchingBasedOnAgentsOption = customBatchSize. Number of tests per batch. Default: 10.
    #batchingBasedOnExecutionTimeOption: 'autoBatchSize' # 'autoBatchSize' | 'customTimeBatchSize'. Optional. Use when distributionBatchType = basedOnExecutionTime. Batch options. Default: autoBatchSize.
    #customRunTimePerBatchValue: '60' # string. Required when distributionBatchType = basedOnExecutionTime && batchingBasedOnExecutionTimeOption = customTimeBatchSize. Running time (sec) per batch. Default: 60.
    #dontDistribute: False # boolean. Replicate tests instead of distributing when multiple agents are used in the job. Default: False.
  # Reporting options
    #testRunTitle: # string. Test run title. 
    #platform: # string. Build platform. 
    #configuration: # string. Build configuration. 
    #publishRunAttachments: true # boolean. Upload test attachments. Default: true.
    #failOnMinTestsNotRun: False # boolean. Fail the task if a minimum number of tests are not run. Default: False.
    #minimumExpectedTests: '1' # string. Optional. Use when failOnMinTestsNotRun = true. Minimum # of tests. Default: 1.
# Visual Studio Test v2
# Run unit and functional tests (Selenium, Appium, Coded UI test, etc.) using the Visual Studio Test (VsTest) runner. Test frameworks that have a Visual Studio test adapter such as MsTest, xUnit, NUnit, Chutzpah (for JavaScript tests using QUnit, Mocha and Jasmine), etc. can be run. Tests can be distributed on multiple agents using this task (version 2).
- task: VSTest@2
  inputs:
  # Test selection
    testSelector: 'testAssemblies' # 'testAssemblies' | 'testPlan' | 'testRun'. Required. Select tests using. Default: testAssemblies.
    testAssemblyVer2: # string. Required when testSelector = testAssemblies. Test files. 
    #testPlan: # string. Required when testSelector = testPlan. Test plan. 
    #testSuite: # string. Required when testSelector = testPlan. Test suite. 
    #testConfiguration: # string. Required when testSelector = testPlan. Test configuration. 
    #tcmTestRun: '$(test.RunId)' # string. Optional. Use when testSelector = testRun. Test Run. Default: $(test.RunId).
    searchFolder: '$(System.DefaultWorkingDirectory)' # string. Required. Search folder. Default: $(System.DefaultWorkingDirectory).
    #testFiltercriteria: # string. Optional. Use when testSelector = testAssemblies. Test filter criteria. 
    #runOnlyImpactedTests: False # boolean. Optional. Use when testSelector = testAssemblies. Run only impacted tests. Default: False.
    #runAllTestsAfterXBuilds: '50' # string. Optional. Use when testSelector = testAssemblies && runOnlyImpactedTests = true. Number of builds after which all tests should be run. Default: 50.
    #uiTests: false # boolean. Test mix contains UI tests. Default: false.
  # Execution options
    #vstestLocationMethod: 'version' # 'version' | 'location'. Select test platform using. Default: version.
    #vsTestVersion: 'latest' # 'latest' | '16.0' | '15.0' | '14.0' | 'toolsInstaller'. Optional. Use when vstestLocationMethod = version. Test platform version. Default: latest.
    #vstestLocation: # string. Optional. Use when vstestLocationMethod = location. Path to vstest.console.exe. 
    #runSettingsFile: # string. Settings file. 
    #overrideTestrunParameters: # string. Override test run parameters. 
    #pathtoCustomTestAdapters: # string. Path to custom test adapters. 
    #runInParallel: False # boolean. Run tests in parallel on multi-core machines. Default: False.
    #runTestsInIsolation: False # boolean. Run tests in isolation. Default: False.
    #codeCoverageEnabled: False # boolean. Code coverage enabled. Default: False.
    #otherConsoleOptions: # string. Other console options. 
    #diagnosticsEnabled: false # boolean. Collect advanced diagnostics in case of catastrophic failures. Default: false.
    #collectDumpOn: 'onAbortOnly' # 'onAbortOnly' | 'always' | 'never'. Optional. Use when diagnosticsEnabled = true. Collect process dump and attach to test run report. Default: onAbortOnly.
    #rerunFailedTests: False # boolean. Rerun failed tests. Default: False.
    #rerunType: 'basedOnTestFailurePercentage' # 'basedOnTestFailurePercentage' | 'basedOnTestFailureCount'. Optional. Use when rerunFailedTests = true. Do not rerun if test failures exceed specified threshold. Default: basedOnTestFailurePercentage.
    #rerunFailedThreshold: '30' # string. Optional. Use when rerunFailedTests = true && rerunType = basedOnTestFailurePercentage. % failure. Default: 30.
    #rerunFailedTestCasesMaxLimit: '5' # string. Optional. Use when rerunFailedTests = true && rerunType = basedOnTestFailureCount. # of failed tests. Default: 5.
    #rerunMaxAttempts: '3' # string. Optional. Use when rerunFailedTests = true. Maximum # of attempts. Default: 3.
  # Advanced execution options
    #distributionBatchType: 'basedOnTestCases' # 'basedOnTestCases' | 'basedOnExecutionTime' | 'basedOnAssembly'. Batch tests. Default: basedOnTestCases.
    #batchingBasedOnAgentsOption: 'autoBatchSize' # 'autoBatchSize' | 'customBatchSize'. Optional. Use when distributionBatchType = basedOnTestCases. Batch options. Default: autoBatchSize.
    #customBatchSizeValue: '10' # string. Required when distributionBatchType = basedOnTestCases && batchingBasedOnAgentsOption = customBatchSize. Number of tests per batch. Default: 10.
    #batchingBasedOnExecutionTimeOption: 'autoBatchSize' # 'autoBatchSize' | 'customTimeBatchSize'. Optional. Use when distributionBatchType = basedOnExecutionTime. Batch options. Default: autoBatchSize.
    #customRunTimePerBatchValue: '60' # string. Required when distributionBatchType = basedOnExecutionTime && batchingBasedOnExecutionTimeOption = customTimeBatchSize. Running time (sec) per batch. Default: 60.
    #dontDistribute: False # boolean. Replicate tests instead of distributing when multiple agents are used in the job. Default: False.
  # Reporting options
    #testRunTitle: # string. Test run title. 
    #platform: # string. Build platform. 
    #configuration: # string. Build configuration. 
    #publishRunAttachments: true # boolean. Upload test attachments. Default: true.
# Visual Studio Test v2
# Run unit and functional tests (Selenium, Appium, Coded UI test, etc.) using the Visual Studio Test (VsTest) runner. Test frameworks that have a Visual Studio test adapter such as MsTest, xUnit, NUnit, Chutzpah (for JavaScript tests using QUnit, Mocha and Jasmine), etc. can be run. Tests can be distributed on multiple agents using this task (version 2).
- task: VSTest@2
  inputs:
  # Test selection
    testSelector: 'testAssemblies' # 'testAssemblies' | 'testPlan' | 'testRun'. Required. Select tests using. Default: testAssemblies.
    testAssemblyVer2: # string. Required when testSelector = testAssemblies. Test files. 
    #testPlan: # string. Required when testSelector = testPlan. Test plan. 
    #testSuite: # string. Required when testSelector = testPlan. Test suite. 
    #testConfiguration: # string. Required when testSelector = testPlan. Test configuration. 
    #tcmTestRun: '$(test.RunId)' # string. Optional. Use when testSelector = testRun. Test Run. Default: $(test.RunId).
    searchFolder: '$(System.DefaultWorkingDirectory)' # string. Required. Search folder. Default: $(System.DefaultWorkingDirectory).
    #testFiltercriteria: # string. Optional. Use when testSelector = testAssemblies. Test filter criteria. 
    #runOnlyImpactedTests: False # boolean. Optional. Use when testSelector = testAssemblies. Run only impacted tests. Default: False.
    #runAllTestsAfterXBuilds: '50' # string. Optional. Use when testSelector = testAssemblies && runOnlyImpactedTests = true. Number of builds after which all tests should be run. Default: 50.
    #uiTests: false # boolean. Test mix contains UI tests. Default: false.
  # Execution options
    #vstestLocationMethod: 'version' # 'version' | 'location'. Select test platform using. Default: version.
    #vsTestVersion: 'latest' # 'latest' | '16.0' | '15.0' | '14.0' | 'toolsInstaller'. Optional. Use when vstestLocationMethod = version. Test platform version. Default: latest.
    #vstestLocation: # string. Optional. Use when vstestLocationMethod = location. Path to vstest.console.exe. 
    #runSettingsFile: # string. Settings file. 
    #overrideTestrunParameters: # string. Override test run parameters. 
    #pathtoCustomTestAdapters: # string. Path to custom test adapters. 
    #runInParallel: False # boolean. Run tests in parallel on multi-core machines. Default: False.
    #runTestsInIsolation: False # boolean. Run tests in isolation. Default: False.
    #codeCoverageEnabled: False # boolean. Code coverage enabled. Default: False.
    #otherConsoleOptions: # string. Other console options. 
    #diagnosticsEnabled: True # boolean. Collect advanced diagnostics in case of catastrophic failures. Default: True.
    #collectDumpOn: 'onAbortOnly' # 'onAbortOnly' | 'always' | 'never'. Optional. Use when diagnosticsEnabled = true. Collect process dump and attach to test run report. Default: onAbortOnly.
    #rerunFailedTests: False # boolean. Rerun failed tests. Default: False.
    #rerunType: 'basedOnTestFailurePercentage' # 'basedOnTestFailurePercentage' | 'basedOnTestFailureCount'. Optional. Use when rerunFailedTests = true. Do not rerun if test failures exceed specified threshold. Default: basedOnTestFailurePercentage.
    #rerunFailedThreshold: '30' # string. Optional. Use when rerunFailedTests = true && rerunType = basedOnTestFailurePercentage. % failure. Default: 30.
    #rerunFailedTestCasesMaxLimit: '5' # string. Optional. Use when rerunFailedTests = true && rerunType = basedOnTestFailureCount. # of failed tests. Default: 5.
    #rerunMaxAttempts: '3' # string. Optional. Use when rerunFailedTests = true. Maximum # of attempts. Default: 3.
  # Advanced execution options
    #distributionBatchType: 'basedOnTestCases' # 'basedOnTestCases' | 'basedOnExecutionTime' | 'basedOnAssembly'. Batch tests. Default: basedOnTestCases.
    #batchingBasedOnAgentsOption: 'autoBatchSize' # 'autoBatchSize' | 'customBatchSize'. Optional. Use when distributionBatchType = basedOnTestCases. Batch options. Default: autoBatchSize.
    #customBatchSizeValue: '10' # string. Required when distributionBatchType = basedOnTestCases && batchingBasedOnAgentsOption = customBatchSize. Number of tests per batch. Default: 10.
    #batchingBasedOnExecutionTimeOption: 'autoBatchSize' # 'autoBatchSize' | 'customTimeBatchSize'. Optional. Use when distributionBatchType = basedOnExecutionTime. Batch options. Default: autoBatchSize.
    #customRunTimePerBatchValue: '60' # string. Required when distributionBatchType = basedOnExecutionTime && batchingBasedOnExecutionTimeOption = customTimeBatchSize. Running time (sec) per batch. Default: 60.
    #dontDistribute: False # boolean. Do not distribute tests and replicate instead when multiple agents are used in the job. Default: False.
  # Reporting options
    #testRunTitle: # string. Test run title. 
    #platform: # string. Build platform. 
    #configuration: # string. Build configuration. 
    #publishRunAttachments: true # boolean. Upload test attachments. Default: true.

入力

testSelector - を使用してテストを選択する
string. 必須です。 使用できる値: testAssemblies (テスト アセンブリ)、 testPlan (テスト プラン)、 testRun (テスト実行)。 既定値: testAssemblies

  • テスト アセンブリ: テストを含む 1 つ以上のテスト アセンブリを指定します。 必要に応じてフィルター条件を指定して、特定のテストのみを選択できます。
  • テスト計画: 自動テスト メソッドが関連付けられているテスト 計画からテストを実行します。 テストをテスト ケース作業項目に関連付ける方法の詳細については、「自動テストとテスト ケースを関連付ける」を参照してください。
  • テストの実行: このオプションは、 テスト 計画からテストを実行する環境を設定する場合に使用します。 このオプションは、継続的インテグレーションと継続的デプロイ (CI/CD) パイプラインでテストを実行するときには使わないでください。

testAssemblyVer2 - テスト ファイル
string. testSelector = testAssemblies の場合に必要です。 既定値: **\bin\**\*test.dll\n**\bin\**\*tests.dll

指定したファイルからテストを実行します。 順序を指定したテストと Web テストは、それぞれ .orderedtest.webtest ファイルを指定して実行できます。 .webtest を実行するには、Visual Studio 2017 Update 4 以降が必要です。 ファイル パスは検索フォルダーからの相対パスです。 この入力では、複数行の ミニマッチ パターンがサポートされます

# Example
- task: VSTest@2
  inputs:
    testSelector: 'testAssemblies'
    testAssemblyVer2: |
      **\*test*.dll
      !**\*TestAdapter.dll
      !**\obj\**

testAssemblyVer2 - テスト ファイル
string. testSelector = testAssemblies の場合に必要です。 既定値: **\*test*.dll\n!**\*TestAdapter.dll\n!**\obj\**

指定したファイルからテストを実行します。 順序を指定したテストと Web テストは、それぞれ .orderedtest.webtest ファイルを指定して実行できます。 .webtest を実行するには、Visual Studio 2017 Update 4 以降が必要です。 ファイル パスは検索フォルダーからの相対パスです。 この入力では、複数行の ミニマッチ パターンがサポートされます

# Example
- task: VSTest@2
  inputs:
    testSelector: 'testAssemblies'
    testAssemblyVer2: |
      **\*test*.dll
      !**\*TestAdapter.dll
      !**\obj\**

testPlan - テスト計画
string. testSelector = testPlan の場合に必要です。

自動テスト ケースを含むテスト スイートを含むテスト 計画を指定します。


testSuite - テスト スイート
string. testSelector = testPlan の場合に必要です。

自動テスト ケースを含む 1 つ以上のテスト スイートを指定します。 テスト ケースの作業項目は、 自動テスト メソッドに関連付ける必要があります。


testConfiguration - テスト構成
string. testSelector = testPlan の場合に必要です。

テスト構成を指定します。


tcmTestRun - テスト実行
string. 省略可能。 の場合は testSelector = testRunを使用します。 既定値: $(test.RunId)

テスト 計画から自動テスト実行をトリガーするときに使用するテスト実行ベースの選択を指定します。 CI/CD パイプラインでのテスト実行には、このオプションを使用できません。


searchFolder - Search フォルダー
string. 必須です。 既定値: $(System.DefaultWorkingDirectory)

テスト アセンブリを検索するフォルダーを指定します。


resultsFolder - テスト結果フォルダー
string. 既定値: $(Agent.TempDirectory)\TestResults

テスト結果を格納するフォルダーを指定します。 既定のディレクトリを使用すると、パイプラインの実行の最後にクリーンアップされます。 結果ディレクトリは、テストが実行される前に、タスクの vstest 開始時に常にクリーンアップされます。 相対フォルダー パスが指定されている場合は、 に対する $(Agent.TempDirectory)相対パスと見なされます。


testFiltercriteria - フィルター条件をテストする
string. 省略可能。 の場合は testSelector = testAssembliesを使用します。

テスト アセンブリからテストをフィルター処理するための追加の条件を指定します。 (例: Priority=1|Name=MyTestMethod)。 コマンド ライン オプションについて説明します。


runOnlyImpactedTests - 影響を受けたテストのみを実行する
boolean. 省略可能。 の場合は testSelector = testAssembliesを使用します。 既定値: False

コードの変更を検証するために必要なテストを自動的に指定して実行します。 テスト影響分析の使用について説明します。


runAllTestsAfterXBuilds - すべてのテストを実行するビルドの数
string. 省略可能。 の場合は testSelector = testAssemblies && runOnlyImpactedTests = trueを使用します。 既定値: 50

すべてのテストが自動的に実行される前に実行されるビルドの数を指定します。 テスト影響分析にはテスト ケースとソース コード間のマッピングが格納されます。 すべてのテストを定期的に実行して、マッピングを再生成することをお勧めします。


uiTests - テスト ミックスには UI テストが含まれています
boolean. 既定値: false

UI テストを実行するには、自動ログオンが有効になっている対話型モードで実行するようにエージェントが設定されていることを確認します。 対話形式で実行するエージェントの設定は、ビルドまたはリリースをキューに登録する前に行う必要があります。 このチェックボックスをオンにしても、エージェントは自動的に対話モードには構成されません。 このオプションは、障害を回避するためにエージェントを適切に構成するためのリマインダーとして機能します。 VS 2015 と 2017 プールのホステッド Windows エージェントは、UI テストを実行するために使用できます。


vstestLocationMethod - を使用してテスト プラットフォームを選択する
string. 使用できる値: versionlocation (特定の場所)。 既定値: version

使用するテスト プラットフォームを指定します。


vsTestVersion - プラットフォームのバージョンをテストする
string. 省略可能。 の場合は vstestLocationMethod = versionを使用します。 使用できる値: latest、(Visual Studio 2022)、 16.0 (Visual Studio 2019) 15.0 、(Visual Studio 2017) 14.0 、(Visual Studio 2015) toolsInstaller 、(ツール インストーラーによって 17.0 インストール)。 既定値: latest

使用する Visual Studio テストのバージョンを指定します。 latest が指定されている場合、この入力は、インストールされている最新バージョン (許可された値の一覧から) を選択します。 エージェントで Visual Studio を必要とせずにテストを実行するには、[ ツールインストーラーによってインストール] オプションを使用します。 NuGet からテスト プラットフォームを取得するには、 必ず Visual Studio テスト プラットフォーム インストーラー タスクを含めるようにしてください。


vsTestVersion - プラットフォームのバージョンをテストする
string. 省略可能。 の場合は vstestLocationMethod = versionを使用します。 使用できる値: latest、(Visual Studio 2019)、 15.0 (Visual Studio 2017) 14.0 、(Visual Studio 2015) toolsInstaller 、(Installed by Tools 16.0 Installer)。 既定値: latest

使用する Visual Studio テストのバージョンを指定します。 latest が指定されている場合、この入力は、インストールされている最新バージョン (許可された値の一覧から) を選択します。 エージェントで Visual Studio を必要とせずにテストを実行するには、[ ツールインストーラーによってインストール] オプションを使用します。 NuGet からテスト プラットフォームを取得するには、 必ず Visual Studio テスト プラットフォーム インストーラー タスクを含めるようにしてください。


vstestLocation - vstest.console.exeへのパス
string. 省略可能。 の場合は vstestLocationMethod = locationを使用します。

VSTest へのパスを指定します。


runSettingsFile - 設定ファイル
string.

テストで使用する または testsettings ファイルへのrunsettingsパスを指定します。 Visual Studio 15.7 以降では、すべてのテストの種類に を使用 runsettings します。 ファイルからファイルへの.runsettings変換の.testsettings詳細については、こちらを参照してください。


overrideTestrunParameters - テスト実行パラメーターをオーバーライドする
string.

ファイルのセクションまたはファイルのTestRunParametersrunsettingsセクションで定義されているパラメーターをPropertiestestsettingsオーバーライドします。 (例: -key1 value1 -key2 value2)。 メモ: ファイルで testsettings 指定されたプロパティには、Visual Studio 2017 (更新プログラム 4 以降) を使用して TestContext アクセスできます。


pathtoCustomTestAdapters - カスタム テスト アダプターへのパス
string.

カスタム テスト アダプターへのディレクトリ パスを指定します。 テスト アセンブリと同じフォルダーにあるアダプターは自動的に検出されます。


runInParallel - マルチコア マシンでテストを並列で実行する
boolean. 既定値: False

に設定すると true、テストは並列で実行され、マシンの使用可能なコアが活用されます。 これにより、ファイルで が MaxCpuCount 指定されている場合は が runsettings オーバーライドされます。 テストを並列で実行する方法の詳細については、こちらを参照してください。


runTestsInIsolation - テストを分離して実行する
boolean. 既定値: False

分離プロセスでテストを実行します。 これにより、vstest.console.exe テスト プロセスのエラーが少なくなる可能性がありますが、テストの実行速度が低下する可能性があります。 [複数エージェント] ジョブ設定を使って実行する場合、現在、このオプションは使用できません。


codeCoverageEnabled - コード カバレッジが有効
boolean. 既定値: False

テスト実行からコード カバレッジ情報を収集します。


otherConsoleOptions - その他のコンソール オプション
string.

vstest.console.exe に渡すことができるその他のコンソール オプション

これらのオプションはサポートされておらず、エージェント ジョブの 複数エージェント並列 設定を使用してテストを実行する場合、 テストプラン または テスト 実行オプションを使用してテストを実行するとき、またはカスタムバッチ処理オプションが選択されている場合は無視されます。 これらのオプションは設定ファイルを使って指定することもできます。


distributionBatchType - バッチ テスト
string. 使用できる値: basedOnTestCases (テストとエージェントの数に基づく)、 basedOnExecutionTime (テストの過去の実行時間に基づく) basedOnAssembly 、(テスト アセンブリに基づく)。 既定値: basedOnTestCases

バッチはテストのグループです。 テストのバッチは同時にテストを実行し、結果はバッチに対して発行されます。 タスクによって実行されるジョブが、複数のエージェントを使うように設定されている場合、並列で実行するテストのバッチは各エージェントによって選択されます。 バッチは次のように実行できます。

テストとエージェントの数に基づいています。 テストの実行に参加しているテストとエージェントの数に基づく単純なバッチ処理。

テストの過去の実行時間に基づいて。 このバッチ処理では、過去の実行時間を考慮して、各バッチの実行時間がほぼ等しいテストのバッチを作成します。

テスト アセンブリに基づいています。 アセンブリからのテストはバッチ処理されます。


batchingBasedOnAgentsOption - バッチ オプション
string. 省略可能。 の場合は distributionBatchType = basedOnTestCasesを使用します。 使用できる値: autoBatchSize (バッチ サイズを自動的に決定する) customBatchSize 、(バッチ サイズを指定します)。 既定値: autoBatchSize

テストの実行に参加しているテストとエージェントの数に基づいて、単純なバッチ処理を指定します。 バッチ サイズが自動的に決定される場合、各バッチには (total number of tests / number of agents) 個のテストが含まれます。 バッチ サイズを指定した場合、各バッチには指定した数のテストが含まれます。


customBatchSizeValue - バッチあたりのテスト数
string. distributionBatchType = basedOnTestCases && batchingBasedOnAgentsOption = customBatchSize の場合に必要です。 既定値: 10

バッチ サイズを指定します。


batchingBasedOnExecutionTimeOption - バッチ オプション
string. 省略可能。 の場合は distributionBatchType = basedOnExecutionTimeを使用します。 使用できる値: autoBatchSize (バッチ時刻を自動的に決定する) customTimeBatchSize 、(バッチあたりの実行時間を指定します)。 既定値: autoBatchSize

このバッチ処理では、過去の実行時間を考慮して、各バッチの実行時間がほぼ等しいテストのバッチを作成します。 クイック実行テストは一緒にバッチ処理されますが、実行時間の長いテストは別のバッチに属している可能性があります。 マルチエージェント ジョブ設定でこのオプションを使用すると、テスト時間の合計が最小に短縮されます。


customRunTimePerBatchValue - バッチあたりの実行時間 (秒)
string. distributionBatchType = basedOnExecutionTime && batchingBasedOnExecutionTimeOption = customTimeBatchSize の場合に必要です。 既定値: 60

バッチあたりの実行時間 (秒単位) を指定します。


dontDistribute - ジョブで複数のエージェントが使用される場合に配布するのではなく、テストをレプリケートする
boolean. 既定値: False

このオプションを選択しても、タスクがマルチエージェント ジョブで実行されている場合、エージェント間でテストは分散されません。 選んだ各テストは、各エージェントで繰り返されます。 このオプションは、エージェント ジョブが並列処理なしで、またはマルチ構成オプションを使用して実行するように構成されている場合は適用されません。


dontDistribute - ジョブで複数のエージェントが使用されている場合は、代わりにテストを分散してレプリケートしないでください
boolean. 既定値: False

このオプションを選択しても、タスクがマルチエージェント ジョブで実行されている場合、エージェント間でテストは分散されません。 選んだ各テストは、各エージェントで繰り返されます。 このオプションは、エージェント ジョブが並列処理なしで、またはマルチ構成オプションを使用して実行するように構成されている場合は適用されません。


testRunTitle - テスト実行のタイトル
string.

テスト実行の名前を指定します。


platform - プラットフォームをビルドする
string.

テストを報告するビルド プラットフォームを指定します。 ビルド タスクでプラットフォームの変数を定義している場合は、この入力でこれを使用します。


configuration - ビルド構成
string.

テストを報告するビルド構成を指定します。 ビルド タスクで構成用の変数を定義している場合は、この入力でその変数を使用します。


publishRunAttachments - テスト添付ファイルをアップロードする
boolean. 既定値: true

実行レベルの添付ファイルの発行をオプトインまたはオプトアウトします。


failOnMinTestsNotRun - テストの最小数が実行されていない場合は、タスクを失敗させます。
boolean. 既定値: False

最小数のテストが実行されていない場合、タスクは失敗します。 これが役に立つのは、タスクの入力や基となるテスト アダプターの依存関係に変更があり、必要なテストの一部しか見つからなくなった場合です。


minimumExpectedTests - テストの最小数
string. 省略可能。 の場合は failOnMinTestsNotRun = trueを使用します。 既定値: 1

タスクが成功するために実行するテストの最小数を指定します。 実行されたテストの合計は、成功したテスト、失敗したテスト、および中止されたテストの合計として計算されます。


diagnosticsEnabled - 致命的な障害が発生した場合に高度な診断を収集する
boolean. 既定値: false

診断データを収集して、テスト クラッシュなどの致命的なエラーのトラブルシューティングを行います。 このオプションをオンにすると、シーケンス XML ファイルが生成され、テスト実行に添付されます。 シーケンス ファイルには、テストが実行されたシーケンスに関する情報が含まれているため、潜在的な原因テストを特定できます。


diagnosticsEnabled - 致命的な障害が発生した場合に高度な診断を収集する
boolean. 既定値: True

診断データを収集して、テスト クラッシュなどの致命的なエラーのトラブルシューティングを行います。 このオプションをオンにすると、シーケンス XML ファイルが生成され、テスト実行に添付されます。 シーケンス ファイルには、テストが実行されたシーケンスに関する情報が含まれているため、潜在的な原因テストを特定できます。


collectDumpOn - プロセス ダンプを収集し、テスト実行レポートにアタッチする
string. 省略可能。 の場合は diagnosticsEnabled = trueを使用します。 使用できる値: onAbortOnly (中止時のみ)、 alwaysnever。 既定値: onAbortOnly

詳細な分析に使用できるミニ ダンプを収集します。

  • onAbortOnly - ミニ ダンプは、テストの実行が中止された場合にのみ収集されます。
  • Always - テストの実行が完了したかどうかに関係なく、ミニ ダンプは常に収集されます。
  • なし - テストの実行が完了したかどうかに関係なく、ミニ ダンプは収集されません。

rerunFailedTests - 失敗したテストを再実行する
boolean. 既定値: False

失敗したテストが成功するまで、または試行の最大数に達するまで再実行します。


rerunType - テストエラーが指定されたしきい値を超えた場合は再実行しないでください
string. 省略可能。 の場合は rerunFailedTests = trueを使用します。 使用できる値: basedOnTestFailurePercentage (% failure)、 basedOnTestFailureCount (失敗したテストの数)。 既定値: basedOnTestFailurePercentage

エラー率が指定したしきい値を超えたときに、テストの再実行を回避します。 これは、環境の問題によって大規模な障害が発生する場合に適用されます。 失敗の割合または失敗したテストの数をしきい値として指定できます。


rerunFailedThreshold - % 失敗
string. 省略可能。 の場合は rerunFailedTests = true && rerunType = basedOnTestFailurePercentageを使用します。 既定値: 30

失敗したテスト ケースの割合が指定したしきい値を超えた場合に、テストの再実行を回避します。 これは、環境の問題によって大規模な障害が発生する場合に適用されます。


rerunFailedTestCasesMaxLimit - 失敗したテストの数
string. 省略可能。 の場合は rerunFailedTests = true && rerunType = basedOnTestFailureCountを使用します。 既定値: 5

失敗したテスト ケースの数が指定した制限を超えたときに、テストの再実行を回避します。 これは、環境の問題によって大規模な障害が発生する場合に適用されます。


rerunMaxAttempts - 最大試行回数
string. 省略可能。 の場合は rerunFailedTests = trueを使用します。 既定値: 3

失敗したテストを再試行する最大回数を指定します。 試行の最大数に達する前にテストが成功した場合、再び再実行されることはありません。


タスク制御オプション

すべてのタスクには、タスク入力に加えて制御オプションがあります。 詳細については、「 コントロール オプションと一般的なタスク プロパティ」を参照してください。

出力変数

[なし] :

解説

このタスクを使用して、Visual Studio テスト ランナーを使用して単体テストと機能テスト (Selenium、Appium、コード化された UI テストなど) を実行します。 MSTest ベースのテストと共に、Visual Studio テスト アダプターを持つテスト フレームワーク (xUnit、NUnit、Chutzpah など) を実行することもできます。

ターゲット .NET Core フレームワークを使うテストは、.runsettings ファイルで適切なターゲット フレームワーク値を指定することで実行できます。

このタスクのバージョン 2 を使って、複数のエージェントにテストを配布できます。 詳細については、「Visual Studio テスト タスクを使用してテストを並列で実行する」を参照してください。

前提条件を確認する

Windows セルフホステッド エージェントを使用している場合は、次の前提条件をインストールする必要があります。

確認要求

エージェントには、次の機能が必要です。

vstest

vstest の要求は、次の 2 つの方法で満たすことができます。

  1. Visual Studio をエージェント マシンにインストールします。
  2. パイプライン定義で Visual Studio テスト プラットフォーム インストーラー タスクを使います。

TestCase をデータ ソースとして使うテストを実行するにはどうすればよいですか?

TestCase をデータ ソースとして使う自動テストを実行するには、以下が必要です。

  1. エージェント マシン上に Visual Studio 2017.6 以降が必要です。 TestCase をデータ ソースとして使うテストを実行するには、Visual Studio テスト プラットフォーム インストーラー タスクを実行できません。
  2. スコープの “作業項目 (フル)“ の権限を与えられた PAT を作成します。
  3. 前の手順で作成した PAT に値を設定して、 という Test.TestCaseAccessToken セキュリティで保護されたビルドまたはリリース変数を追加します。

タスク オプションの一部でデータ駆動型の xUnit テストと NUnit テストを実行すると、問題が発生します。 既知の制限はありますか?

xUnit と NUnit のテスト フレームワークを使うデータ駆動型テストには、いくつかの既知の制限があり、次のタスク オプションと共に使うことはできません。

  1. 失敗したテストの再実行。
  2. 複数エージェントでのテストの分散とバッチ処理のオプション。
  3. テスト影響分析。

上記の制限は、これらのテスト フレームワークのアダプターがデータ駆動型テストを検出し、報告する方法に起因しています。

VSTest タスクは、一度に複数のターゲット フレームワークを対象とするテストの実行をサポートしていますか?

はい。バージョン 17.3 VSTest 以降では、一度に複数のターゲット フレームワークを対象とするテストの実行がサポートされます。 それ以前は、 VSTest プラットフォーム 側からの制限により、これは不可能でした。

複数のターゲット フレームワークに属するテストを実行する場合は、Visual Studio Test Platform Installer を使用して互換性のあるバージョンの VSTest をインストールし、 を にtoolsInstaller設定vsTestVersionして使用する必要があります。

テスト結果の公開中に、次のエラーが表示されます。テスト結果の発行に失敗しました:無効な優先度が指定されていますか?

このエラーは、いずれかのテスト メソッドに 255 を超える優先度が設定されている場合に発生し、コード内のテスト メソッドの優先度を修正して、テストを再実行します。 生成された trx ファイルを確認して、優先度が 255 を超えるすべてのテストを確認できます。

要件

要件 説明
パイプラインの種類 YAML、クラシック ビルド、クラシック リリース
上で実行 エージェント、DeploymentGroup
確認要求 セルフホステッド エージェントには、このタスクを使用するジョブを実行するための次の要求に一致する機能が必要です。
Capabilities このタスクは、ジョブ内の後続のタスクに対する要求を満たしていません。
コマンドの制限 Any
設定可能な変数 Any
エージェントのバージョン 2.103.0 以上
タスクのカテゴリ テスト