Running your tests
As TUnit is built on-top of the newer Microsoft.Testing.Platform, and combined with the fact that TUnit tests are source generated, running your tests is available in a variety of ways.
Please note that for the coverage and trx report, you need to install additional extensions
dotnet runâ
For a simple execution of a project, dotnet run is the preferred method, allowing easier passing in of command line flags.
cd 'C:/Your/Test/Directory'
dotnet run -c Release
# or with flags
dotnet run -c Release --report-trx --coverage
dotnet testâ
dotnet test requires any command line flags to be specified as application arguments, meaning after a -- - Otherwise you'll get an error about unknown switches.
cd 'C:/Your/Test/Directory'
dotnet test -c Release
# or with flags
dotnet test -c Release -- --report-trx --coverage
dotnet execâ
If your test project has already been built, you can use dotnet exec or just dotnet with the .dll path
cd 'C:/Your/Test/Directory/bin/Release/net8.0'
dotnet exec YourTestProject.dll
# or with flags
dotnet exec YourTestProject.dll --report-trx --coverage
or
cd 'C:/Your/Test/Directory/bin/Release/net8.0'
dotnet YourTestProject.dll
# or with flags
dotnet YourTestProject.dll --report-trx --coverage
Published Test Projectâ
When you publish your test project, you'll be given an executable.
On windows this'll be a .exe and on Linux/MacOS there'll be no extension.
This can be invoked directly and passed any flags.
cd 'C:/Your/Test/Directory/bin/Release/net8.0/win-x64/publish'
./YourTestProject.exe
# or with flags
./YourTestProject.exe --report-trx --coverage
IDE Support
Visual Studioâ
Visual Studio is supported. The "Use testing platform server mode" option must be selected in Tools > Manage Preview Features.

Riderâ
Rider is supported.
The Enable Testing Platform support option must be selected in Settings > Build, Execution, Deployment > Unit Testing > Testing Platform.

VS Codeâ
Visual Studio Code is supported.
- Install the extension Name: C# Dev Kit
- Go to the C# Dev Kit extension's settings
- Enable Dotnet > Test Window > Use Testing Platform Protocol

What's Next?â
You've successfully learned the basics of TUnit! You can now:
- Write tests with the
[Test]attribute - Run them via command line or your IDE
- See your test results
To continue your journey with TUnit, explore these topics:
Core Testing Concepts:
- Assertions - Learn TUnit's fluent assertion syntax
- Test Lifecycle - Set up and tear down test state with hooks
- Data-Driven Testing - Run tests with multiple input values
Common Tasks:
- Mocking - Use mocks and fakes in your tests
- Best Practices - Write maintainable, reliable tests
- Cookbook - Common testing patterns and recipes
Advanced Features:
- Parallelism - Control how tests run in parallel
- CI/CD Integration - Integrate TUnit into your pipeline
Need help? Check the Troubleshooting & FAQ guide.