Skip to content

Repository files navigation

ParallelTestingSample-dotnet-core

GitHub licenseBuild Status

This .NET 10 parallel testing sample uses --list-tests and --filter parameters of dotnet test to slice the tests. The tests are run using the NUnit.

This sample has the 100 tests, and slices them to 20 tests in 5 jobs. You can see the pipeline behavior result by clicking the build status badge above.

For the GitHub Actions equivalent, see the GitHub Actions overview.

Overview of azure-pipelines.yml

Setting up parallel count

jobs:
- job: 'ParallelTesting'pool:
vmImage: 'ubuntu-latest'strategy:
parallel: 5displayName: Run tests in parallel

Make slicing condition

  • Get test name list of all tests by using --list-tests parameter and grep Test_
  • create_slicing_filter_condition.sh makes filter condition to slice the tests, and set into $(targetTestsFilter)
 - bash: | tests=($(dotnet test . --no-build --list-tests | grep Test_)) . 'create_slicing_filter_condition.sh' $tests displayName: 'Create slicing filter condition'

Run tests using slicing condition

 - task: DotNetCoreCLI@2displayName: Testinputs:
command: testprojects: '**/*Tests/*Tests.csproj'arguments: '--no-build --filter "$(targetTestsFilter)"'

References

About

Sample for running dotnet core tests in parallel across multiple agents in Azure DevOps

Topics

Resources

Stars

27 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages