Yes, you can run the VSTest task on a different agent/container without disturbing the order of previous tasks by using container jobs in Azure DevOps.
Use the container property in YAML to specify a different container for the VSTest task.
trigger:
- master
pool:
vmImage: 'ubuntu-latest'
jobs:
- job: BuildAndDeploy
container: my-default-container
steps:
- script: echo "Running previous tasks in default container"
- task: AzurePowerShell@5
inputs:
azureSubscription: 'xxxx'
ScriptType: 'FilePath'
ScriptPath: 'test.ps1'
pwsh: true
- job: RunVSTest
dependsOn: BuildAndDeploy # Ensures previous tasks complete first
container: my-vstest-container
steps:
- script: echo "Running VSTest in a different container"
- task: VSTest@2
inputs:
testSelector: 'testAssemblies'
testAssemblyVer2: '**\*test.dll'
Hope this helps!
Please Let me know if you have any queries.
If you found the information helpful, please click "Upvote" on the post to let us know and consider accepting the answer as the token of appreciation. Thank You.