Ever had tests fail intermittently due to network issues, timing problems, or external service hiccups? dotnet-test-rerun solves this by automatically rerunning failed tests, making your test suites more resilient and your CI/CD pipelines more reliable.
| Feature | Description |
|---|---|
| π Smart Retry | Automatically reruns only failed tests with configurable attempts |
| π― Selective Execution | Targets specific tests with filters instead of rerunning everything |
| π Multiple Loggers | Supports trx, junit, console, and custom test loggers |
| π³ Docker Ready | Pre-built images for .NET 8.0, 9.0, and 10.0 |
| βοΈ Highly Configurable | Extensive options for filtering, delays, and test execution |
| π Code Coverage | Collect and merge coverage reports across retry attempts |
| β‘ Performance First | Efficient execution by targeting only failed tests |
| π§ CI/CD Optimized | Built-in support for GitHub Actions, Azure DevOps, GitLab CI |
# Install as a global .NET tool
dotnet tool install --global dotnet-test-rerun# Run tests with automatic retry (default: 3 attempts)
test-rerun path/to/test.dll
# Customize retry attempts
test-rerun path/to/test.dll --rerunMaxAttempts 5
# Add delay between retries (useful for external dependencies)
test-rerun path/to/test.dll --rerunMaxAttempts 5 --delay 10# Use the latest stable version (.NET 10.0)
docker run joaoopereira/dotnet-test-rerun:latest path/to/test.dll --rerunMaxAttempts 3
# Or specify a .NET version
docker run joaoopereira/dotnet-test-rerun:4.0.0-net8 path/to/test.dllπ Integration Tests with External Services
test-rerun IntegrationTests.dll \
--filter "Category=Integration" \
--rerunMaxAttempts 5 \
--delay 10 \
--rerunMaxFailedTests 15Perfect for tests that interact with databases, APIs, or microservices that may have transient failures.
π CI/CD Pipeline Integration
# GitHub Actions example
- name: Run Tests with Retry
run: |
test-rerun tests/**/*.dll \
--configuration Release \
--rerunMaxAttempts 3 \
--logger "trx;LogFileName=results.trx" \
--results-directory ./TestResultsMake your CI/CD pipelines more resilient to intermittent failures.
π Code Coverage Collection
test-rerun MyTests.dll \
--collect "XPlat Code Coverage" \
--mergeCoverageFormat Cobertura \
--rerunMaxAttempts 3Collect and merge coverage reports even when tests need multiple attempts to pass.
π UI/Selenium Tests
test-rerun UITests.dll \
--filter "Category=UI" \
--rerunMaxAttempts 10 \
--delay 3 \
--blameHandle flaky UI tests with generous retry attempts and blame mode for debugging.
dotnet tool install --global dotnet-test-rerun
test-rerun --helpβ
Available system-wide |
docker pull joaoopereira/dotnet-test-rerun:latest
docker run joaoopereira/dotnet-test-rerun:latestβ
No installation needed |
Other options: Local Tool β’ NuGet Package
| Option | Default | Description |
|---|---|---|
--rerunMaxAttempts |
3 |
Maximum number of retry attempts |
--rerunMaxFailedTests |
-1 |
Maximum failed tests to rerun (no limit) |
--delay, -d |
- | Delay between retries in seconds |
--filter |
- | Run tests matching the expression |
--deleteReports |
false |
Clean up report files after execution |
| Option | Description |
|---|---|
--configuration, -c |
Build configuration (Debug/Release) |
--framework, -f |
Target framework to test |
--no-build |
Skip building before testing |
--blame |
Enable blame mode for diagnostics |
--collect |
Enable data collectors (e.g., code coverage) |
| Option | Default | Description |
|---|---|---|
--logger, -l |
trx |
Test result logger (trx, junit, console) |
--results-directory, -r |
- | Output directory for test results |
--loglevel |
Verbose |
Tool log level |
--verbosity, -v |
- | dotnet test verbosity level |
π View All Options β’ Configuration Guide β’ Examples
| Tag Pattern | .NET Runtime | Use Case |
|---|---|---|
latest, {version} |
.NET 10.0 | Latest stable release |
{version}-net10 |
.NET 10.0 | Explicit .NET 10.0 |
{version}-net9 |
.NET 9.0 | .NET 9.0 projects |
{version}-net8 |
.NET 8.0 | .NET 8.0 projects (LTS) |
Example:
docker run joaoopereira/dotnet-test-rerun:4.0.0-net8 tests/MyTests.dll --rerunMaxAttempts 3π³ Docker Hub Repository β’ Docker Guide
Contributions are welcome! We appreciate:
- π Bug reports and fixes
- β¨ New features and enhancements
- π Documentation improvements
- π‘ Ideas and suggestions
Get Started:
- Check the Contributing Guide
- Browse Open Issues
JoΓ£o Pereira
π Website β’ πΌ GitHub
β Star this project if it helped you!
π¦ Share with your network
π¬ Discuss your use cases
Copyright Β© 2023-2024 JoΓ£o Pereira
This project is licensed under the GNU General Public License v3.0 - see the LICENSE file for details.
Important: This tool currently supports English only. The output of dotnet test may be localized, and if it is not in English, the tool may not function correctly.
Made with β€οΈ for the .NET community
Documentation β’ NuGet β’ Docker Hub