I am getting the error "Validating stage:The selected stage does not have the right version or settings of the Visual Studio Test task to run tests. Learn more" when trying to run tests from a test plan on Azure DevOps.
Learn more links to this article:
We performed quiet a bit of searching, but none of them worked for us. This could be a simple setting that we are overlooking. Your help is greatly appreciated.
Complete steps to reproduce the problem:
- Login to your DevOps account
- Create a test plan, call it 'TestPlan"
- Add a single test to the plan, and note the test case ID (let's say 65)
- On your local machine, open VS 2019 using Git as your source control
- Create an MS Test project using C# and .net 4.6.2, call it "TestProject"
- Add a single test to the project, name it TC65_UnitTest1, and execute the test
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace TestProject
{
[TestClass]
public class TC65_UnitTest1
{
[TestMethod]
public void TC65_TestMethod1()
{
// Test 1
Assert.IsTrue(true);
}
}
}
- From visual studio Test Explorer, associate the test case "TC65_TestMethod" with test case ID 65.
- Push your repo to Azure
- From Azure, create a build pipeline follwoing the steps in this article "https://learn.microsoft.com/en-us/azure/devops/test/run-automated-tests-from-test-hub?view=azure-devops"
- My build yml file is shown bellow
- Run the build pipeline
- Create a release pipeline with 2 tasks
- Run the release pipeline
- Open the test plan on Azure notice that test case ID 65 passed
- Still on the test plan, click on "Execute"
- Select "Run with options"
- On the dialog pop up, select "
- Click "Run"
- Expected the test case to show pass. Instead, I get the following error
#AzureDevops.yml
trigger: none
pool:
vmImage: 'windows-latest'
demands: vstest
steps:
- task: DotNetCoreCLI@2
displayName: '1. Build Solution'
inputs:
command: 'build'
projects: '**/*.csproj'
- task: VSTest@3
displayName: '2. Run Tests'
inputs:
testSelector: 'testAssemblies'
testAssemblyVer2: |
!**\*
**\bin\Debug\net462\TestProject.dll
searchFolder: '$(System.DefaultWorkingDirectory)'
codeCoverageEnabled: false # Disable code coverage
- task: PublishBuildArtifacts@1
displayName: '3. Publish Build Artifacts'
inputs:
PathtoPublish: 'TestProject'
I followed the article:
I was expecting to execute a test case from the test plan on Azure DevOps, but I encountered an error.