# TUnit > Welcome to TUnit Testing This file contains links to documentation sections following the llmstxt.org standard. ## Table of Contents - [Exception Handling](https://tunit.dev/docs/advanced/exception-handling): TUnit provides a comprehensive exception hierarchy to help you understand and handle different types of failures that can occur during test executi... - [Extension Points](https://tunit.dev/docs/advanced/extension-points): TUnit provides several extension points that allow you to customize and extend the framework's behavior. These interfaces enable you to implement c... - [Performance Best Practices](https://tunit.dev/docs/advanced/performance-best-practices): This guide provides recommendations for optimizing test performance and ensuring your TUnit test suite runs efficiently. - [Test Variants](https://tunit.dev/docs/advanced/test-variants): Test variants enable you to dynamically create additional test cases during test execution based on runtime results. This powerful feature unlocks ... - [And Conditions](https://tunit.dev/docs/assertions/and-conditions): TUnit can chain assertions together, using the `And` property. This reads very much like English, and aims to keep the test easy to read and unders... - [Assertion Groups](https://tunit.dev/docs/assertions/assertion-groups): Mixing 'Or' & 'And' conditions within `Assert.That(...)` statements may result in unexpected logic. - [Awaiting](https://tunit.dev/docs/assertions/awaiting): In TUnit you `await` your assertions, and this serves two purposes: - [Boolean Assertions](https://tunit.dev/docs/assertions/boolean): TUnit provides simple, expressive assertions for testing boolean values. These assertions work with both `bool` and `bool?` (nullable boolean) types. - [Collection Assertions](https://tunit.dev/docs/assertions/collections): TUnit provides comprehensive assertions for testing collections, including membership, count, ordering, and equivalency checks. These assertions wo... - [DateTime and Time Assertions](https://tunit.dev/docs/assertions/datetime): TUnit provides comprehensive assertions for date and time types, including `DateTime`, `DateTimeOffset`, `DateOnly`, `TimeOnly`, and `TimeSpan`, wi... - [Delegates](https://tunit.dev/docs/assertions/delegates): TUnit can execute your delegates for you, and this allows you to assert on the data returned (if any was) - Or on any exceptions thrown: - [Dictionary Assertions](https://tunit.dev/docs/assertions/dictionaries): TUnit provides specialized assertions for testing dictionaries (`IReadOnlyDictionary`), including key and value membership checks. Di... - [Equality and Comparison Assertions](https://tunit.dev/docs/assertions/equality-and-comparison): TUnit provides comprehensive assertions for testing equality and comparing values. These assertions work with any type that implements the appropri... - [Exception Assertions](https://tunit.dev/docs/assertions/exceptions): TUnit provides comprehensive assertions for testing that code throws (or doesn't throw) exceptions, with rich support for validating exception type... - [Custom Assertions](https://tunit.dev/docs/assertions/extensibility/custom-assertions): The TUnit Assertions can be easily extended so that you can create your own assertions. - [Chaining and Converting](https://tunit.dev/docs/assertions/extensibility/extensibility-chaining-and-converting): TUnit allows you to chain assertions that change the type being asserted, enabling fluent and expressive test code. - [Returning Data via `await`](https://tunit.dev/docs/assertions/extensibility/extensibility-returning-items-from-await): Sometimes, you may want your assertion to return a value, such as an item found in a collection, so you can use it in further assertions or logic. - [Source Generator Assertions](https://tunit.dev/docs/assertions/extensibility/source-generator-assertions): TUnit provides source generators to simplify creating custom assertions. Instead of manually writing assertion classes and extension methods, you c... - [FSharp](https://tunit.dev/docs/assertions/fsharp): As awaiting doesn't work quite the same in F#, the syntax instead looks like this: - [Getting Started with Assertions](https://tunit.dev/docs/assertions/getting-started): TUnit provides a comprehensive, fluent assertion library that makes your tests readable and expressive. This guide introduces the core concepts and... - [Assertions Library](https://tunit.dev/docs/assertions/library): Searchable library of all TUnit assertions - [Member Assertions](https://tunit.dev/docs/assertions/member-assertions): The `.Member()` method allows you to assert on object properties while maintaining the parent object's context for chaining. This is useful when yo... - [Null and Default Value Assertions](https://tunit.dev/docs/assertions/null-and-default): TUnit provides assertions for testing null values and default values. These assertions integrate with C#'s nullability annotations to provide bette... - [Numeric Assertions](https://tunit.dev/docs/assertions/numeric): TUnit provides comprehensive assertions for testing numeric values, including specialized assertions for positive/negative values and comparison as... - [Or Conditions](https://tunit.dev/docs/assertions/or-conditions): Similar to the `And` property, there is also the `Or` property. - [Regex Assertions](https://tunit.dev/docs/assertions/regex-assertions): The `.Matches()` method allows you to validate strings against regular expressions and assert on capture groups, match positions, and match lengths... - [Assertion Scopes](https://tunit.dev/docs/assertions/scopes): In TUnit you can create an assertion scope by calling `Assert.Multiple()`. This returns an `IDisposable` and so you should use that by encapsulatin... - [Specialized Type Assertions](https://tunit.dev/docs/assertions/specialized-types): TUnit provides assertions for many specialized .NET types beyond the common primitives. This page covers GUID, HTTP, file system, networking, and o... - [String Assertions](https://tunit.dev/docs/assertions/string): TUnit provides rich assertions for testing strings, including substring matching, pattern matching, length checks, and various string comparison op... - [Task and Async Assertions](https://tunit.dev/docs/assertions/tasks-and-async): TUnit provides specialized assertions for testing `Task` and `Task` objects, including state checking, completion timeouts, and async exception ... - [Type Checking](https://tunit.dev/docs/assertions/type-checking): TUnit assertions try to check the types at compile time. - [Type Assertions](https://tunit.dev/docs/assertions/types): TUnit provides comprehensive assertions for testing types and type properties. These assertions work with both runtime values and `Type` objects th... - [AsyncTests](https://tunit.dev/docs/benchmarks/AsyncTests): Performance benchmark results for AsyncTests - [Build Performance](https://tunit.dev/docs/benchmarks/BuildTime): Compilation time benchmark results - [DataDrivenTests](https://tunit.dev/docs/benchmarks/DataDrivenTests): Performance benchmark results for DataDrivenTests - [MassiveParallelTests](https://tunit.dev/docs/benchmarks/MassiveParallelTests): Performance benchmark results for MassiveParallelTests - [MatrixTests](https://tunit.dev/docs/benchmarks/MatrixTests): Performance benchmark results for MatrixTests - [ScaleTests](https://tunit.dev/docs/benchmarks/ScaleTests): Performance benchmark results for ScaleTests - [SetupTeardownTests](https://tunit.dev/docs/benchmarks/SetupTeardownTests): Performance benchmark results for SetupTeardownTests - [Performance Benchmarks](https://tunit.dev/docs/benchmarks): Real-world performance comparisons between TUnit and other .NET testing frameworks - [Benchmark Methodology](https://tunit.dev/docs/benchmarks/methodology): How TUnit's performance benchmarks are measured and compared - [Attributes](https://tunit.dev/docs/comparison/attributes): Here are TUnit's equivalent attributes to other test frameworks. - [Framework Differences](https://tunit.dev/docs/comparison/framework-differences): TUnit is inspired by NUnit and xUnit, and first and foremost I want to say that these are amazing frameworks and no hate to them. - [Argument Formatters](https://tunit.dev/docs/customization-extensibility/argument-formatters): When writing data-driven tests, especially with custom classes as arguments, the test explorer may only show the class name, making it hard to dist... - [Data Source Generators](https://tunit.dev/docs/customization-extensibility/data-source-generators): TUnit provides several base classes for creating custom data source generators: - [Display Names](https://tunit.dev/docs/customization-extensibility/display-names): If you want simple control over the name of a test, you can use the `[DisplayName(...)]` attribute. - [Libraries](https://tunit.dev/docs/customization-extensibility/libraries): If you want a library package to define things like re-useable base classes with hooks etc, then you shouldn't use the main `TUnit` package - As th... - [Logging](https://tunit.dev/docs/customization-extensibility/logging): By default, TUnit will intercept any logs to the `Console`, and attempt to correlate them to the test that triggered that log by the current async ... - [ASP.NET Core Web App/Api](https://tunit.dev/docs/examples/aspnet): If you want to test a web app, you can utilise the Microsoft.Mvc.Testing packages to wrap your web app within an in-memory test server. - [Complex Test Infrastructure Orchestration](https://tunit.dev/docs/examples/complex-test-infrastructure): TUnit provides a property injection system that can help orchestrate complex test infrastructure setups. This page demonstrates how TUnit handles t... - [File based C# application](https://tunit.dev/docs/examples/filebased-csharp): Starting with dotnet 10 (preview 4), you can use the new file-based C# application feature to run tests in a more straightforward way. - [F# Interactive](https://tunit.dev/docs/examples/fsharp-interactive): F# Interactive (FSI) is a REPL (Read-Eval-Print Loop) for F#. It allows you to execute F# code interactively, making it a powerful tool for testing... - [Instrumenting: Global Test IDs](https://tunit.dev/docs/examples/instrumenting-global-test-ids): There are plenty use cases for having a unique identifier for each test in your test suite. If you're engineering tests that connect to a data sour... - [Examples](https://tunit.dev/docs/examples/intro): This can serve as a place to show how to use TUnit to test more complex systems, utilising advanced features like ClassData sources with IAsyncInit... - [Playwright](https://tunit.dev/docs/examples/playwright): There is a NuGet package to help with Playwright: `TUnit.Playwright` - [TUnit in CI/CD Pipelines](https://tunit.dev/docs/examples/tunit-ci-pipeline): When using TUnit in a CI/CD pipeline, you'll want to run tests, collect results, and publish reports for visibility. This guide provides complete, ... - [CI/CD Reporting](https://tunit.dev/docs/execution/ci-cd-reporting): TUnit provides built-in integration with continuous integration and deployment platforms, automatically detecting and adapting to various CI enviro... - [Engine Modes](https://tunit.dev/docs/execution/engine-modes): TUnit supports two execution modes, providing flexibility for different development and deployment scenarios. - [Executors](https://tunit.dev/docs/execution/executors): In some advanced cases, you may need to control how a test or hook is executed. - [Repeating](https://tunit.dev/docs/execution/repeating): If you want to repeat a test, add a `[RepeatAttribute]` onto your test method or class. This takes an `int` of how many times you'd like to repeat.... - [Retrying](https://tunit.dev/docs/execution/retrying): Unfortunately sometimes our tests hit issues. It could be a blip on the network, but that could cause our entire test suite to fail which is frustr... - [Test Filters](https://tunit.dev/docs/execution/test-filters): Running TUnit via `dotnet run` supports test filters. - [Timeouts](https://tunit.dev/docs/execution/timeouts): If you want to stop a test after a specified amount of time, add a `[Timeout]` attribute onto your test method or class. This takes an `int` of how... - [Dynamically Created Tests](https://tunit.dev/docs/experimental/dynamic-tests): TUnit offers the ability to create your tests via dynamic code, as opposed to the standard `[Test]` attribute and data attributes. - [Extensions](https://tunit.dev/docs/extensions/extensions): As TUnit is built on top of Microsoft.Testing.Platform, it can tap into generic testing extension packages. - [Installing TUnit](https://tunit.dev/docs/getting-started/installation): Assuming you have the .NET SDK installed, simply run: - [Running your tests](https://tunit.dev/docs/getting-started/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 te... - [Writing your first test](https://tunit.dev/docs/getting-started/writing-your-first-test): Here's a complete TUnit test class with all necessary using statements: - [Best Practices](https://tunit.dev/docs/guides/best-practices): This guide covers best practices for writing clean, maintainable, and robust tests with TUnit. Following these patterns will help you create a test... - [Testing Cookbook](https://tunit.dev/docs/guides/cookbook): This cookbook provides practical, copy-paste examples for common testing scenarios with TUnit. Each recipe is a complete, working example you can a... - [TUnit Philosophy & Design Decisions](https://tunit.dev/docs/guides/philosophy): If you're wondering why TUnit does things differently from other testing frameworks, this page has the answers. Understanding the reasoning behind ... - [Intro](https://tunit.dev/docs/intro): **TUnit** is another testing framework for C# / .NET. - [Migrating from MSTest](https://tunit.dev/docs/migration/mstest): :::from-mstest Performance Boost - [Migrating from NUnit](https://tunit.dev/docs/migration/nunit): :::from-nunit Performance Boost - [TestContext Interface Organization Migration Guide](https://tunit.dev/docs/migration/testcontext-interface-organization): TUnit has reorganized the `TestContext` API to provide a cleaner, more discoverable interface structure. Properties and methods are now organized i... - [Migrating from xUnit.net](https://tunit.dev/docs/migration/xunit): :::from-xunit Performance Boost - [Not in Parallel](https://tunit.dev/docs/parallelism/not-in-parallel): By default, TUnit tests will run in parallel. - [Parallel Groups](https://tunit.dev/docs/parallelism/parallel-groups): Parallel Groups are an alternative parallel mechanism to [NotInParallel]. - [Parallel Limiter](https://tunit.dev/docs/parallelism/parallel-limiter): TUnit allows the user to control the parallel limit on a test, class or assembly level. - [Command Line Flags](https://tunit.dev/docs/reference/command-line-flags): :::info - [Test Configuration](https://tunit.dev/docs/reference/test-configuration): TUnit supports having a `testconfig.json` file within your test project. - [AOT Compatibility and Generic Tests](https://tunit.dev/docs/test-authoring/aot-compatibility): TUnit's source generation mode provides compile-time safety and performance benefits, but requires specific patterns for advanced scenarios like ge... - [Data Driven Tests](https://tunit.dev/docs/test-authoring/arguments): It's common to want to repeat tests but pass in different values on each execution. - [Injectable Class Data Source](https://tunit.dev/docs/test-authoring/class-data-source): The `ClassDataSource` attribute is used to instantiate and inject in new classes as parameters to your tests and/or test classes. - [CombinedDataSources - Quick Reference](https://tunit.dev/docs/test-authoring/combined-data-source-summary): `[CombinedDataSources]` allows you to apply different data source attributes to individual test method parameters, automatically generating all pos... - [CombinedDataSources](https://tunit.dev/docs/test-authoring/combined-data-source): The `[CombinedDataSources]` attribute enables you to apply different data source attributes to individual parameters, creating test cases through C... - [Culture](https://tunit.dev/docs/test-authoring/culture): The `[Culture]` attribute is used to set the [current Culture](https://learn.microsoft.com/en-us/dotnet/api/system.globalization.cultureinfo.curren... - [Depends On](https://tunit.dev/docs/test-authoring/depends-on): :::warning Test Isolation Best Practice - [Explicit](https://tunit.dev/docs/test-authoring/explicit): If you want a test to only be run explicitly (and not part of all general tests) then you can add the `[ExplicitAttribute]`. - [Generic Attributes](https://tunit.dev/docs/test-authoring/generic-attributes): TUnit provides generic versions of several attributes that offer enhanced type safety and better IDE support. These attributes allow you to specify... - [Matrix Tests](https://tunit.dev/docs/test-authoring/matrix-tests): The Matrix data source is a way to specify different arguments per parameter, and then generate every possible combination of all of those arguments. - [Method Data Sources](https://tunit.dev/docs/test-authoring/method-data-source): A limitation of passing data in with `[Arguments(...)]` is that the data must be `constant` values. For example, we can't new up an object and pass... - [Mocking](https://tunit.dev/docs/test-authoring/mocking): TUnit is a testing framework focused on test execution and does not include any built-in mocking capabilities. This gives you the freedom to choose... - [Nested Data Sources with Initialization](https://tunit.dev/docs/test-authoring/nested-data-sources): When writing integration tests, you often need complex test fixtures that depend on other initialized resources. TUnit's nested data source initial... - [Ordering Tests](https://tunit.dev/docs/test-authoring/order): :::warning - [Skipping Tests](https://tunit.dev/docs/test-authoring/skip): If you want to simply skip a test, just place a `[Skip(reason)]` attribute on your test with an explanation of why you're skipping it. - [Things to know](https://tunit.dev/docs/test-authoring/things-to-know): TUnit has made some decisions by design. You may need to know about them: - [Class Constructor Helpers](https://tunit.dev/docs/test-lifecycle/class-constructors): Some test suites might be more complex than others, and a user may want control over 'newing' up their test classes. - [Test Clean Ups](https://tunit.dev/docs/test-lifecycle/cleanup): TUnit supports having your test class implement `IDisposable` or `IAsyncDisposable`. These will be called after your test has finished executing. H... - [Dependency Injection](https://tunit.dev/docs/test-lifecycle/dependency-injection): Dependency Injection can be set up by leveraging the power of the Data Source Generators. - [Event Subscribing](https://tunit.dev/docs/test-lifecycle/event-subscribing): Objects associated with your tests have the ability to subscribe to lifecycle events generated by TUnit. - [Properties](https://tunit.dev/docs/test-lifecycle/properties): Custom properties can be added to a test using the `[PropertyAttribute]`. - [Property Injection](https://tunit.dev/docs/test-lifecycle/property-injection): TUnit's AOT-compatible property injection system makes it easy to initialize properties on your test class with compile-time safety and excellent p... - [Test Set Ups](https://tunit.dev/docs/test-lifecycle/setup): Most setup for a test can be performed in the constructor (think setting up mocks, assigning fields.) - [Test Context](https://tunit.dev/docs/test-lifecycle/test-context): All tests have a `TestContext` object available to them. - [Troubleshooting & FAQ](https://tunit.dev/docs/troubleshooting): This guide covers common questions and issues you might encounter when using TUnit.