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.
jobs:
- job: 'ParallelTesting'
pool:
name: Hosted Ubuntu 1604
strategy:
parallel: 5
displayName: Run tests in parallel
- Get test name list of all tests by using
--list-tests
parameter andgrep 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'
- task: DotNetCoreCLI@2
displayName: Test
inputs:
command: test
projects: '**/*Tests/*Tests.csproj'
arguments: '--no-build --filter "$(targetTestsFilter)"'