diff --git a/Tasks/VsTestV2/Strings/resources.resjson/en-US/resources.resjson b/Tasks/VsTestV2/Strings/resources.resjson/en-US/resources.resjson index e02d55f1abe0..9825141bbd4f 100644 --- a/Tasks/VsTestV2/Strings/resources.resjson/en-US/resources.resjson +++ b/Tasks/VsTestV2/Strings/resources.resjson/en-US/resources.resjson @@ -22,6 +22,8 @@ "loc.input.help.tcmTestRun": "Test run based selection is used when triggering automated test runs from the test hub. This option cannot be used for running tests in the CI/CD pipeline.", "loc.input.label.searchFolder": "Search folder", "loc.input.help.searchFolder": "Folder to search for the test assemblies.", + "loc.input.label.resultsFolder": "Test results folder", + "loc.input.help.resultsFolder": "Folder to store test results. When this input is not specified, results are stored in $(Agent.TempDirectory)/TestResults by default, which is cleaned at the end of a pipeline run. The results directory will always be cleaned up at the start of the vstest task before the tests are run. Relative folder path if provided will be considered relative to $(Agent.TempDirectory)", "loc.input.label.testFiltercriteria": "Test filter criteria", "loc.input.help.testFiltercriteria": "Additional criteria to filter tests from Test assemblies. For example: `Priority=1|Name=MyTestMethod`. [More information](https://msdn.microsoft.com/en-us/library/jj155796.aspx)", "loc.input.label.runOnlyImpactedTests": "Run only impacted tests", diff --git a/Tasks/VsTestV2/inputparser.ts b/Tasks/VsTestV2/inputparser.ts index 5f25f6f421e0..59316f5e81da 100644 --- a/Tasks/VsTestV2/inputparser.ts +++ b/Tasks/VsTestV2/inputparser.ts @@ -166,6 +166,31 @@ function getTestReportingSettings(inputDataContract : idc.InputDataContract) : i inputDataContract.TestReportingSettings.TestRunTitle = tl.getInput('testRunTitle'); inputDataContract.TestReportingSettings.TestRunSystem = 'VSTS - vstest'; + const resultsDir = path.resolve(tl.getVariable('Agent.TempDirectory'), tl.getInput('resultsFolder')); + inputDataContract.TestReportingSettings.TestResultsDirectory = resultsDir; + tl.debug("TestResultsFolder: " + resultsDir); + + if (resultsDir.startsWith(tl.getVariable('Agent.TempDirectory') + 'TestResults')) + { + ci.publishEvent({ 'TestResultsFolderUi': '$(Agent.TempDirectory)/TestResults' } ); + } + else if (resultsDir.startsWith(tl.getVariable('Agent.TempDirectory'))) + { + ci.publishEvent({ 'TestResultsFolderUi': '$(Agent.TempDirectory)' } ); + } + else if (resultsDir.startsWith(tl.getVariable('Common.TestResultsDirectory'))) + { + ci.publishEvent({ 'TestResultsFolderUi': '$(Common.TestResultsDirectory)' }) + } + else if (resultsDir.startsWith(tl.getVariable('System.DefaultWorkingDirectory'))) + { + ci.publishEvent({ 'TestResultsFolderUi': '$(System.DefaultWorkingDirectory)' }) + } + else + { + ci.publishEvent({ 'TestResultsFolderUi': 'Custom Directory' }) + } + inputDataContract.TestReportingSettings.TestSourceSettings = {}; inputDataContract.TestReportingSettings.TestSourceSettings.PullRequestTargetBranchName = tl.getVariable('System.PullRequest.TargetBranch'); inputDataContract.TestReportingSettings.ExecutionStatusSettings = {}; diff --git a/Tasks/VsTestV2/make.json b/Tasks/VsTestV2/make.json index 66a0ebea83d1..9d4352757614 100644 --- a/Tasks/VsTestV2/make.json +++ b/Tasks/VsTestV2/make.json @@ -6,7 +6,7 @@ "dest": "./" }, { - "url": "https://testexecution.blob.core.windows.net/testexecution/10932935/TestAgent.zip", + "url": "https://testexecution.blob.core.windows.net/testexecution/10965943/TestAgent.zip", "dest": "./Modules" }, { @@ -40,4 +40,4 @@ "options": "-Rf" } ] -} \ No newline at end of file +} diff --git a/Tasks/VsTestV2/task.json b/Tasks/VsTestV2/task.json index 34bdd8c8985f..5143990b9376 100644 --- a/Tasks/VsTestV2/task.json +++ b/Tasks/VsTestV2/task.json @@ -18,7 +18,7 @@ "version": { "Major": 2, "Minor": 162, - "Patch": 1 + "Patch": 2 }, "demands": [ "vstest" @@ -145,6 +145,15 @@ "helpMarkDown": "Folder to search for the test assemblies.", "groupName": "testSelection" }, + { + "name": "resultsFolder", + "type": "string", + "label": "Test results folder", + "defaultValue": "$(Agent.TempDirectory)\\TestResults", + "required": false, + "helpMarkDown": "Folder to store test results. When this input is not specified, results are stored in $(Agent.TempDirectory)/TestResults by default, which is cleaned at the end of a pipeline run. The results directory will always be cleaned up at the start of the vstest task before the tests are run. Relative folder path if provided will be considered relative to $(Agent.TempDirectory)", + "groupName": "testSelection" + }, { "name": "testFiltercriteria", "type": "string", @@ -641,4 +650,4 @@ "LookingForBuildToolsInstalltion": "Attempting to find vstest.console from a visual studio build tools installation with version %s.", "LookingForVsInstalltion": "Attempting to find vstest.console from a visual studio installation with version %s." } -} \ No newline at end of file +} diff --git a/Tasks/VsTestV2/task.loc.json b/Tasks/VsTestV2/task.loc.json index 3a29737af194..30ed4683f902 100644 --- a/Tasks/VsTestV2/task.loc.json +++ b/Tasks/VsTestV2/task.loc.json @@ -18,7 +18,7 @@ "version": { "Major": 2, "Minor": 162, - "Patch": 1 + "Patch": 2 }, "demands": [ "vstest" @@ -145,6 +145,15 @@ "helpMarkDown": "ms-resource:loc.input.help.searchFolder", "groupName": "testSelection" }, + { + "name": "resultsFolder", + "type": "string", + "label": "ms-resource:loc.input.label.resultsFolder", + "defaultValue": "$(Agent.TempDirectory)\\TestResults", + "required": false, + "helpMarkDown": "ms-resource:loc.input.help.resultsFolder", + "groupName": "testSelection" + }, { "name": "testFiltercriteria", "type": "string",