diff --git a/Tasks/VsTest/Strings/resources.resjson/en-US/resources.resjson b/Tasks/VsTest/Strings/resources.resjson/en-US/resources.resjson index 15db21d4f8de..3e9101233f3c 100644 --- a/Tasks/VsTest/Strings/resources.resjson/en-US/resources.resjson +++ b/Tasks/VsTest/Strings/resources.resjson/en-US/resources.resjson @@ -4,6 +4,7 @@ "loc.description": "Run tests with Visual Studio test runner", "loc.instanceNameFormat": "Test Assemblies $(testAssembly)", "loc.group.displayName.executionOptions": "Execution Options", + "loc.group.displayName.tiaOptions": "Test Impact Analysis", "loc.group.displayName.advancedExecutionOptions": "Advanced Execution Options", "loc.group.displayName.reportingOptions": "Reporting Options", "loc.input.label.testAssembly": "Test Assembly", @@ -18,6 +19,10 @@ "loc.input.help.codeCoverageEnabled": "Collect code coverage information from the Test run.", "loc.input.label.runInParallel": "Run In Parallel", "loc.input.help.runInParallel": "Enable parallel execution of your tests.", + "loc.input.label.runOnlyImpactedTests": "Run Only Impacted Tests", + "loc.input.help.runOnlyImpactedTests": "Automatically select, and run only the tests needed to validate the code change.", + "loc.input.label.runAllTestsAfterXBuilds": "Number Of Builds After Which To Run All Tests:", + "loc.input.help.runAllTestsAfterXBuilds": "Number of builds after which to automatically run all tests. Test Impact Analysis stores the mapping between test cases and source code. It is recommended to regenerate the mapping by running all tests, on a regular basis.", "loc.input.label.vstestLocationMethod": "VSTest", "loc.input.label.vsTestVersion": "VSTest version", "loc.input.help.vsTestVersion": "The version of VSTest to use.", diff --git a/Tasks/VsTest/VSTest.ps1 b/Tasks/VsTest/VSTest.ps1 index 27b89ef3f0f2..1719074f014d 100644 --- a/Tasks/VsTest/VSTest.ps1 +++ b/Tasks/VsTest/VSTest.ps1 @@ -14,7 +14,9 @@ param( [string]$publishRunAttachments, [string]$runInParallel, [string]$vstestLocationMethod, - [string]$vstestLocation + [string]$vstestLocation, + [string]$runOnlyImpactedTests, + [string]$runAllTestsAfterXBuilds ) Write-Verbose "Entering script VSTest.ps1" @@ -171,7 +173,12 @@ try Write-Verbose "Test results directory: $testResultsDirectory" - + if($runOnlyImpactedTests -eq "True") + { + Write-Warning ("Running all tests. To run only impacted tests, move the task to the node implementation.") + } + + if (![String]::IsNullOrWhiteSpace($vstestLocationInput) -And (InvokeVsTestCmdletHasMember "VSTestLocation")) { Invoke-VSTest -TestAssemblies $testAssemblyFiles -VSTestVersion $vsTestVersion -TestFiltercriteria $testFiltercriteria -RunSettingsFile $runSettingsFileWithParallel -PathtoCustomTestAdapters $pathtoCustomTestAdapters -CodeCoverageEnabled $codeCoverage -OverrideTestrunParameters $overrideTestrunParameters -OtherConsoleOptions $otherConsoleOptions -WorkingFolder $workingDirectory -TestResultsFolder $testResultsDirectory -SourcesDirectory $sourcesDirectory -VSTestLocation $vstestLocationInput diff --git a/Tasks/VsTest/task.json b/Tasks/VsTest/task.json index 01e26491c039..083c1b69aefa 100644 --- a/Tasks/VsTest/task.json +++ b/Tasks/VsTest/task.json @@ -13,7 +13,7 @@ "version": { "Major": 1, "Minor": 0, - "Patch": 59 + "Patch": 60 }, "demands": [ "vstest" @@ -25,6 +25,12 @@ "displayName": "Execution Options", "isExpanded": true }, + { + "name": "tiaOptions", + "displayName": "Test Impact Analysis", + "isExpanded": true, + "tags" : [ "Preview" ] + }, { "name": "advancedExecutionOptions", "displayName": "Advanced Execution Options", @@ -91,6 +97,24 @@ "helpMarkDown": "Enable parallel execution of your tests.", "groupName": "executionOptions" }, + { + "name": "runOnlyImpactedTests", + "type": "boolean", + "label": "Run Only Impacted Tests", + "defaultValue": "False", + "required": false, + "helpMarkDown": "Automatically select, and run only the tests needed to validate the code change.", + "groupName": "tiaOptions" + }, + { + "name": "runAllTestsAfterXBuilds", + "type": "string", + "label": "Number Of Builds After Which To Run All Tests:", + "defaultValue": "", + "required": false, + "helpMarkDown": "Number of builds after which to automatically run all tests. Test Impact Analysis stores the mapping between test cases and source code. It is recommended to regenerate the mapping by running all tests, on a regular basis.", + "groupName": "tiaOptions" + }, { "name": "vstestLocationMethod", "type": "radio", diff --git a/Tasks/VsTest/task.loc.json b/Tasks/VsTest/task.loc.json index 6010f4a3927b..163e59411d26 100644 --- a/Tasks/VsTest/task.loc.json +++ b/Tasks/VsTest/task.loc.json @@ -13,7 +13,7 @@ "version": { "Major": 1, "Minor": 0, - "Patch": 59 + "Patch": 60 }, "demands": [ "vstest" @@ -25,6 +25,14 @@ "displayName": "ms-resource:loc.group.displayName.executionOptions", "isExpanded": true }, + { + "name": "tiaOptions", + "displayName": "ms-resource:loc.group.displayName.tiaOptions", + "isExpanded": true, + "tags": [ + "Preview" + ] + }, { "name": "advancedExecutionOptions", "displayName": "ms-resource:loc.group.displayName.advancedExecutionOptions", @@ -91,6 +99,24 @@ "helpMarkDown": "ms-resource:loc.input.help.runInParallel", "groupName": "executionOptions" }, + { + "name": "runOnlyImpactedTests", + "type": "boolean", + "label": "ms-resource:loc.input.label.runOnlyImpactedTests", + "defaultValue": "False", + "required": false, + "helpMarkDown": "ms-resource:loc.input.help.runOnlyImpactedTests", + "groupName": "tiaOptions" + }, + { + "name": "runAllTestsAfterXBuilds", + "type": "string", + "label": "ms-resource:loc.input.label.runAllTestsAfterXBuilds", + "defaultValue": "", + "required": false, + "helpMarkDown": "ms-resource:loc.input.help.runAllTestsAfterXBuilds", + "groupName": "tiaOptions" + }, { "name": "vstestLocationMethod", "type": "radio", diff --git a/Tasks/VsTest/vstest.ts b/Tasks/VsTest/vstest.ts index 2d1c3f7307d2..5314cf2b7dee 100644 --- a/Tasks/VsTest/vstest.ts +++ b/Tasks/VsTest/vstest.ts @@ -34,9 +34,9 @@ try { var configuration: string = tl.getInput('configuration'); var publishRunAttachments: string = tl.getInput('publishRunAttachments'); var runInParallel: boolean = tl.getBoolInput('runInParallel'); - var tiaEnabled = tl.getVariable('tia.enabled'); + var tiaEnabled: boolean = tl.getBoolInput('runOnlyImpactedTests'); var fileLevel = tl.getVariable('tia.filelevel'); - var tiaRebaseLimit = tl.getVariable('tia.rebaselimit'); + var tiaRebaseLimit: string = tl.getInput('runAllTestsAfterXBuilds'); var sourcesDir = tl.getVariable('build.sourcesdirectory'); @@ -1088,7 +1088,7 @@ function isEmptyResponseFile(responseFile: string): boolean { } function isTiaAllowed(): boolean { - if (tiaEnabled && tiaEnabled.toUpperCase() == "TRUE" && getTestSelectorLocation()) { + if (tiaEnabled && getTestSelectorLocation()) { return true; } return false;