xUnit test output, traits and skipping tests: ITestOutputHelper, [Trait] and dotnet test --filter
Write test output through ITestOutputHelper (injected into the constructor) instead of Console.WriteLine, tag tests with [Trait] so you can include or exclude them with dotnet test --filter, and skip a …
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | // ====================================================================== // Q: Test output, categories and skipping in xUnit? // // Write test output through ITestOutputHelper (injected into the constructor) // instead of Console.WriteLine, tag tests with [Trait] so you can include or // exclude them with dotnet test --filter, and skip a test temporarily with Skip // and a reason that points to a ticket. // ====================================================================== public class ImportTests(ITestOutputHelper output) // instead of Console.WriteLine { [Fact] [Trait("Category", "Slow")] public void Imports_large_file() { output.WriteLine($"Imported {count} rows"); } [Fact(Skip = "ERP sandbox down until 15/11, ticket SHOP-482")] public void Sends_to_real_erp_sandbox() { } } dotnet test --filter "Category!=Slow" # without the slow tests dotnet test --filter "FullyQualifiedName~Orders" # only tests with "Orders" in the name |