Skip to content

idubnori/ParallelTestingSample-dotnet-core

Repository files navigation

ParallelTestingSample-dotnet-core

GitHub license Build Status

This .NET Core 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.

Overview of azure-pipelines.yml

Setting up parallel count

jobs:
- job: 'ParallelTesting'
  pool:
    vmImage: 'ubuntu-latest'
  strategy:
    parallel: 5
  displayName: 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@2
   displayName: Test
   inputs:
     command: test
     projects: '**/*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

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •