Skip to content

krystianYoyo/dotnet-test-rerun

Β 
Β 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

370 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ”„ dotnet-test-rerun

Automatically rerun failed .NET tests until they pass

Build Status Coverage Status NuGet Version NuGet Downloads Docker Pulls

πŸ“– Documentation β€’ πŸ› Issues


🎯 Why dotnet-test-rerun?

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.

✨ Key Features

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

πŸš€ Quick Start

Installation

# Install as a global .NET tool
dotnet tool install --global dotnet-test-rerun

Basic Usage

# 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

Docker Usage

# 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

πŸ“š Common Use Cases

🌐 Integration Tests with External Services
test-rerun IntegrationTests.dll \
  --filter "Category=Integration" \
  --rerunMaxAttempts 5 \
  --delay 10 \
  --rerunMaxFailedTests 15

Perfect 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 ./TestResults

Make your CI/CD pipelines more resilient to intermittent failures.

πŸ“Š Code Coverage Collection
test-rerun MyTests.dll \
  --collect "XPlat Code Coverage" \
  --mergeCoverageFormat Cobertura \
  --rerunMaxAttempts 3

Collect 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 \
  --blame

Handle flaky UI tests with generous retry attempts and blame mode for debugging.


πŸ“¦ Installation Options

Global Tool (Recommended)

dotnet tool install --global dotnet-test-rerun
test-rerun --help

βœ… Available system-wide
βœ… Easy to update
βœ… Simple command

Docker

docker pull joaoopereira/dotnet-test-rerun:latest
docker run joaoopereira/dotnet-test-rerun:latest

βœ… No installation needed
βœ… Multiple .NET versions
βœ… Isolated environment

Other options: Local Tool β€’ NuGet Package


πŸŽ›οΈ Configuration Options

Core Options

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

Test 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)

Logging & Output

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


🐳 Docker Images

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


🀝 Contributing

Contributions are welcome! We appreciate:

  • πŸ› Bug reports and fixes
  • ✨ New features and enhancements
  • πŸ“– Documentation improvements
  • πŸ’‘ Ideas and suggestions

Get Started:

  1. Check the Contributing Guide
  2. Browse Open Issues

πŸ‘₯ Community

Author

JoΓ£o Pereira
🌐 Website β€’ πŸ’Ό GitHub

Contributors

Contributors

Show Your Support

⭐ Star this project if it helped you!
🐦 Share with your network
πŸ’¬ Discuss your use cases


πŸ“„ License

Copyright Β© 2023-2024 JoΓ£o Pereira

This project is licensed under the GNU General Public License v3.0 - see the LICENSE file for details.


⚠️ Language Support

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

About

automatic rerun dotnet failed tests

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • C# 97.9%
  • Other 2.1%