TUnit.Analyzers
0.1.508
Prefix Reserved
TUnit.Core handles analysis now
See the version list below for details.
dotnet add package TUnit.Analyzers --version 0.1.508
NuGet\Install-Package TUnit.Analyzers -Version 0.1.508
<PackageReference Include="TUnit.Analyzers" Version="0.1.508" />
paket add TUnit.Analyzers --version 0.1.508
#r "nuget: TUnit.Analyzers, 0.1.508"
// Install TUnit.Analyzers as a Cake Addin #addin nuget:?package=TUnit.Analyzers&version=0.1.508 // Install TUnit.Analyzers as a Cake Tool #tool nuget:?package=TUnit.Analyzers&version=0.1.508
TUnit
T(est)Unit!
Documentation
See here: https://thomhurst.github.io/TUnit/
Speed Comparison
We can't get an extremely accurate speed comparison because the test host runs as its own process - So tools like Benchmark.NET won't work.
But I've tried to create 4 equal basic test suites, which all execute a test method with a 50ms Task.Delay, and repeat it 1000 times. Some frameworks don't easily have repeat mechanisms so this may be artificially produced with a test data source.
While a 50ms Task.Delay isn't obviously a test in itself, it still helps to demonstrate how TUnit is fast at runtime, due to using a newer test architecture, source generation, parallelization and async-await all the way down the stack.
See here for the latest speed test comparisons: https://github.com/thomhurst/TUnit/actions/workflows/speed-comparison.yml?query=branch%3Amain
IDE
TUnit is built on top of newer Microsoft.Testing.Platform libraries, as opposed to older legacy VSTest libraries. As of July 2024, IDEs do not fully support this testing platform yet.
Visual Studio Preview versions can run the new tests by enabling the new testing platform server mode, within Visual Studio preview/experimental features. You will have to opt in to this manually.
For Rider, it is not yet supported. I believe they are working on it so we just have to wait for now.
dotnet
CLI - Fully supported. Tests should be runnable with both dotnet test
or dotnet run
. dotnet run
should give you a better experience and make it simpler to pass in test flags!
Features
- Source generated tests
- Full async support
- Parallel by default, with mechanisms to:
- Run specific tests completely on their own
- Run specific tests not in parallel with other specific tests
- Limit the a parallel limit on a per-test, class or assembly level
- Test ordering (if running not in parallel)
- Tests can depend on other tests to form chains, useful for if one test depends on state from another action
- Easy to read assertions
- Injectable test data via classes, methods, compile-time args, or matrices
- Hooks before and after:
- TestDiscover
- TestSession
- Assembly
- Class
- Test
- Designed to avoid common pitfalls such as leaky test states
- Ability to view and interrogate metadata and results from various assembly/class/test context objects
Installation
dotnet add package TUnit --prerelease
Example test
[Test]
public async Task Test1()
{
var value = "Hello world!";
await Assert.That(value)
.Is.Not.Null
.And.Does.StartWith("H")
.And.Has.Count().EqualTo(12)
.And.Is.EqualTo("hello world!", StringComparison.InvariantCultureIgnoreCase);
}
or with more complex test orchestration needs
[Before(Class)]
public static async Task ClearDatabase(ClassHookContext context) { ... }
[After(Class)]
public static async Task AssertDatabaseIsAsExpected(ClassHookContext context) { ... }
[Before(Test)]
public async Task CreatePlaywrightBrowser(TestContext context) { ... }
[After(Test)]
public async Task DisposePlaywrightBrowser(TestContext context) { ... }
[Retry(3)]
[Test, DisplayName("Register an account")]
[EnumerableMethodData(nameof(GetAuthDetails))]
public async Task Register(string username, string password) { ... }
[Repeat(5)]
[Test, DependsOn(nameof(Register))]
[EnumerableMethodData(nameof(GetAuthDetails))]
public async Task Login(string username, string password) { ... }
[Test, DependsOn(nameof(Login), [typeof(string), typeof(string)])]
[EnumerableMethodData(nameof(GetAuthDetails))]
public async Task DeleteAccount(string username, string password) { ... }
[Category("Downloads")]
[Timeout(300_000)]
[Test, NotInParallel(Order = 1)]
public async Task DownloadFile1() { ... }
[Category("Downloads")]
[Timeout(300_000)]
[Test, NotInParallel(Order = 2)]
public async Task DownloadFile2() { ... }
[Repeat(10)]
[Test]
[Arguments(1)]
[Arguments(2)]
[Arguments(3)]
[DisplayName("Go to the page numbered $page")]
public async Task GoToPage(int page) { ... }
[Category("Cookies")]
[Test, Skip("Not yet built!")]
public async Task CheckCookies() { ... }
[Test, Explicit, WindowsOnlyTest, RetryHttpServiceUnavailable(5)]
[Property("Some Key", "Some Value")]
public async Task Ping() { ... }
[Test]
[ParallelLimit<LoadTestParallelLimit>]
[Repeat(1000)]
public async Task LoadHomepage() { ... }
public static IEnumerable<(string Username, string Password)> GetAuthDetails()
{
yield return ("user1", "password1");
yield return ("user2", "password2");
yield return ("user3", "password3");
}
public class WindowsOnlyTestAttribute : SkipAttribute
{
public WindowsOnlyTestAttribute() : base("Windows only test")
{
}
public override Task<bool> ShouldSkip(TestContext testContext)
{
return Task.FromResult(!OperatingSystem.IsWindows());
}
}
public class RetryHttpServiceUnavailableAttribute : RetryAttribute
{
public RetryHttpServiceUnavailableAttribute(int times) : base(times)
{
}
public override Task<bool> ShouldRetry(TestInformation testInformation, Exception exception, int currentRetryCount)
{
return Task.FromResult(exception is HttpRequestException { StatusCode: HttpStatusCode.ServiceUnavailable });
}
}
public class LoadTestParallelLimit : IParallelLimit
{
public int Limit => 50;
}
Motivations
TUnit is inspired by NUnit and xUnit - two of the most popular testing frameworks for .NET.
It aims to build upon the useful features of both while trying to address any pain points that they may have. You may have experienced these, or you may have not even known about them.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Microsoft.CodeAnalysis.CSharp.Workspaces (>= 4.3.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated | |
---|---|---|---|
0.1.984 | 645 | 10/7/2024 | |
0.1.980 | 85 | 10/7/2024 | |
0.1.971 | 79 | 10/7/2024 | |
0.1.966 | 213 | 10/7/2024 | |
0.1.962 | 82 | 10/6/2024 | |
0.1.961 | 89 | 10/6/2024 | |
0.1.958 | 82 | 10/6/2024 | |
0.1.954 | 87 | 10/6/2024 | |
0.1.949 | 86 | 10/6/2024 | |
0.1.942 | 92 | 10/5/2024 | |
0.1.939 | 81 | 10/5/2024 | |
0.1.937 | 89 | 10/5/2024 | |
0.1.934 | 80 | 10/5/2024 | |
0.1.931 | 89 | 10/5/2024 | |
0.1.928 | 93 | 10/4/2024 | |
0.1.923 | 83 | 10/4/2024 | |
0.1.916 | 82 | 10/3/2024 | |
0.1.911 | 92 | 10/3/2024 | |
0.1.897 | 92 | 10/2/2024 | |
0.1.894 | 91 | 10/2/2024 | |
0.1.891 | 89 | 10/2/2024 | |
0.1.885 | 87 | 10/1/2024 | |
0.1.877 | 102 | 9/29/2024 | |
0.1.872 | 96 | 9/29/2024 | |
0.1.869 | 89 | 9/29/2024 | |
0.1.864 | 90 | 9/28/2024 | |
0.1.863 | 89 | 9/28/2024 | |
0.1.857 | 88 | 9/28/2024 | |
0.1.842 | 98 | 9/26/2024 | |
0.1.827 | 91 | 9/25/2024 | |
0.1.818 | 100 | 9/24/2024 | |
0.1.817 | 96 | 9/24/2024 | |
0.1.816 | 91 | 9/24/2024 | |
0.1.812 | 95 | 9/23/2024 | |
0.1.807 | 90 | 9/23/2024 | |
0.1.804 | 114 | 9/22/2024 | |
0.1.801 | 87 | 9/22/2024 | |
0.1.797 | 99 | 9/22/2024 | |
0.1.793 | 116 | 9/21/2024 | |
0.1.791 | 91 | 9/21/2024 | |
0.1.790 | 98 | 9/21/2024 | |
0.1.783 | 98 | 9/20/2024 | |
0.1.773 | 106 | 9/20/2024 | |
0.1.767 | 83 | 9/19/2024 | |
0.1.763 | 94 | 9/19/2024 | |
0.1.762 | 98 | 9/19/2024 | |
0.1.759 | 98 | 9/19/2024 | |
0.1.752 | 103 | 9/18/2024 | |
0.1.741 | 103 | 9/17/2024 | |
0.1.738 | 102 | 9/16/2024 | |
0.1.732 | 95 | 9/16/2024 | |
0.1.720 | 101 | 9/15/2024 | |
0.1.716 | 98 | 9/15/2024 | |
0.1.714 | 97 | 9/15/2024 | |
0.1.711 | 95 | 9/15/2024 | |
0.1.703 | 290 | 9/14/2024 | |
0.1.697 | 183 | 9/14/2024 | |
0.1.691 | 293 | 9/13/2024 | |
0.1.686 | 138 | 9/13/2024 | |
0.1.672 | 370 | 9/12/2024 | |
0.1.667 | 184 | 9/11/2024 | |
0.1.664 | 130 | 9/11/2024 | |
0.1.653 | 237 | 9/11/2024 | |
0.1.639 | 308 | 9/10/2024 | |
0.1.634 | 160 | 9/10/2024 | |
0.1.623 | 299 | 9/7/2024 | |
0.1.600 | 559 | 9/6/2024 | |
0.1.582 | 320 | 9/5/2024 | |
0.1.578 | 116 | 9/5/2024 | |
0.1.575 | 117 | 9/4/2024 | |
0.1.518 | 340 | 9/2/2024 | |
0.1.512 | 1,134 | 8/30/2024 | |
0.1.508 | 116 | 8/29/2024 | |
0.1.506 | 183 | 8/28/2024 | |
0.1.505 | 128 | 8/28/2024 | |
0.1.504 | 107 | 8/28/2024 | |
0.1.503 | 159 | 8/27/2024 | |
0.1.502 | 130 | 8/27/2024 | |
0.1.497 | 105 | 8/27/2024 | |
0.1.495 | 108 | 8/27/2024 | |
0.1.492 | 133 | 8/16/2024 | |
0.1.491 | 128 | 8/15/2024 | |
0.1.486 | 121 | 8/9/2024 | |
0.1.481 | 264 | 8/8/2024 | |
0.1.479 | 114 | 8/8/2024 | |
0.1.476 | 498 | 8/7/2024 | |
0.1.474 | 117 | 8/7/2024 | |
0.1.472 | 108 | 8/7/2024 | |
0.1.471 | 122 | 8/7/2024 | |
0.1.470 | 98 | 8/7/2024 | |
0.1.469 | 95 | 8/7/2024 | |
0.1.467 | 109 | 8/7/2024 | |
0.1.465 | 97 | 8/7/2024 | |
0.1.460 | 124 | 8/6/2024 | |
0.1.459 | 90 | 8/6/2024 | |
0.1.458 | 96 | 8/5/2024 | |
0.1.457 | 104 | 8/1/2024 | |
0.1.456 | 103 | 8/1/2024 | |
0.1.455 | 82 | 7/31/2024 | |
0.1.454 | 65 | 7/30/2024 | |
0.1.442 | 405 | 7/13/2024 | |
0.1.441 | 111 | 7/13/2024 | |
0.1.440 | 108 | 7/13/2024 | |
0.1.439 | 110 | 7/13/2024 | |
0.1.438 | 143 | 7/12/2024 | |
0.1.434 | 90 | 7/12/2024 | |
0.1.433 | 106 | 7/12/2024 | |
0.1.430 | 258 | 7/11/2024 | |
0.1.428 | 116 | 7/10/2024 | |
0.1.424 | 344 | 7/9/2024 | |
0.1.423-alpha01 | 92 | 7/9/2024 | |
0.1.422-alpha01 | 95 | 7/7/2024 | |
0.1.420-alpha01 | 94 | 7/7/2024 | |
0.1.419-alpha01 | 89 | 7/7/2024 | |
0.1.418-alpha01 | 89 | 7/7/2024 | |
0.1.417-alpha01 | 87 | 7/7/2024 | |
0.1.416-alpha01 | 84 | 7/7/2024 | |
0.1.413-alpha01 | 70 | 7/7/2024 | |
0.1.412-alpha01 | 87 | 7/7/2024 | |
0.1.411-alpha01 | 92 | 7/6/2024 | |
0.1.410-alpha01 | 83 | 7/6/2024 | |
0.1.409-alpha01 | 80 | 7/5/2024 | |
0.1.407-alpha01 | 81 | 7/5/2024 | |
0.1.406-alpha01 | 89 | 7/5/2024 | |
0.1.405-alpha01 | 85 | 7/5/2024 | |
0.1.404-alpha01 | 95 | 7/5/2024 | |
0.1.403-alpha01 | 75 | 7/5/2024 | |
0.1.402-alpha01 | 85 | 7/5/2024 | |
0.1.401-alpha01 | 180 | 7/5/2024 | |
0.1.398-alpha01 | 81 | 7/5/2024 | |
0.1.397-alpha01 | 95 | 7/4/2024 | |
0.1.395-alpha01 | 91 | 7/2/2024 | |
0.1.394-alpha01 | 92 | 7/1/2024 | |
0.1.392-alpha01 | 94 | 6/30/2024 | |
0.1.391-alpha01 | 74 | 6/30/2024 | |
0.1.390-alpha01 | 79 | 6/30/2024 | |
0.1.389-alpha01 | 84 | 6/30/2024 | |
0.1.386-alpha01 | 73 | 6/30/2024 | |
0.1.385-alpha01 | 72 | 6/30/2024 | |
0.1.384-alpha01 | 76 | 6/30/2024 | |
0.1.383-alpha01 | 79 | 6/30/2024 | |
0.1.382-alpha01 | 85 | 6/28/2024 | |
0.1.381-alpha01 | 92 | 6/26/2024 | |
0.1.380-alpha01 | 75 | 6/26/2024 | |
0.1.379-alpha01 | 218 | 6/26/2024 | |
0.1.378-alpha01 | 77 | 6/26/2024 | |
0.1.377-alpha01 | 79 | 6/26/2024 | |
0.1.376-alpha01 | 85 | 6/26/2024 | |
0.1.375-alpha01 | 97 | 6/25/2024 | |
0.1.374-alpha01 | 81 | 6/25/2024 | |
0.1.373-alpha01 | 103 | 6/24/2024 | |
0.1.372-alpha01 | 79 | 6/24/2024 | |
0.1.371-alpha01 | 82 | 6/23/2024 | |
0.1.370-alpha01 | 95 | 6/21/2024 | |
0.1.369-alpha01 | 94 | 6/21/2024 | |
0.1.368-alpha01 | 81 | 6/21/2024 | |
0.1.367-alpha01 | 101 | 6/21/2024 | |
0.1.366-alpha01 | 94 | 6/21/2024 | |
0.1.365-alpha01 | 109 | 6/20/2024 | |
0.1.364-alpha01 | 84 | 6/19/2024 | |
0.1.363-alpha01 | 97 | 6/19/2024 | |
0.1.362-alpha01 | 94 | 6/18/2024 | |
0.1.361-alpha01 | 101 | 6/18/2024 | |
0.1.360-alpha01 | 82 | 6/18/2024 | |
0.1.359-alpha01 | 80 | 6/17/2024 | |
0.1.358-alpha01 | 87 | 6/17/2024 | |
0.1.357-alpha01 | 90 | 6/16/2024 | |
0.1.356-alpha01 | 94 | 6/16/2024 | |
0.1.355-alpha01 | 93 | 6/16/2024 | |
0.1.354-alpha01 | 96 | 6/16/2024 | |
0.1.353-alpha01 | 107 | 6/16/2024 | |
0.1.352-alpha01 | 94 | 6/16/2024 | |
0.1.351-alpha01 | 111 | 6/14/2024 | |
0.1.350-alpha01 | 192 | 6/14/2024 | |
0.1.349-alpha01 | 102 | 6/13/2024 | |
0.1.347-alpha01 | 92 | 6/12/2024 | |
0.1.346-alpha01 | 100 | 6/12/2024 | |
0.1.343-alpha01 | 89 | 6/12/2024 | |
0.1.342-alpha01 | 95 | 6/12/2024 | |
0.1.341-alpha01 | 98 | 6/11/2024 | |
0.1.340-alpha01 | 82 | 6/11/2024 | |
0.1.338-alpha01 | 93 | 6/11/2024 | |
0.1.336-alpha01 | 94 | 6/11/2024 | |
0.1.335-alpha01 | 90 | 6/11/2024 | |
0.1.334-alpha01 | 99 | 6/11/2024 | |
0.1.333-alpha01 | 100 | 6/11/2024 | |
0.1.332-alpha01 | 89 | 6/11/2024 | |
0.1.331-alpha01 | 95 | 6/11/2024 | |
0.1.330-alpha01 | 88 | 6/11/2024 | |
0.1.329-alpha01 | 102 | 6/11/2024 | |
0.1.328-alpha01 | 88 | 6/11/2024 | |
0.1.327-alpha01 | 98 | 6/10/2024 | |
0.1.326-alpha01 | 77 | 6/7/2024 | |
0.1.325-alpha01 | 89 | 6/7/2024 | |
0.1.324-alpha01 | 93 | 6/6/2024 | |
0.1.323-alpha01 | 113 | 6/6/2024 | |
0.1.322-alpha01 | 91 | 6/3/2024 | |
0.1.321-alpha01 | 85 | 6/3/2024 | |
0.1.320-alpha01 | 110 | 6/2/2024 | |
0.1.319-alpha01 | 86 | 6/2/2024 | |
0.1.318-alpha01 | 103 | 6/2/2024 | |
0.1.317-alpha01 | 98 | 6/2/2024 | |
0.1.316-alpha01 | 105 | 6/2/2024 | |
0.1.315-alpha01 | 100 | 5/31/2024 | |
0.1.314-alpha01 | 95 | 5/30/2024 | |
0.1.313-alpha01 | 104 | 5/30/2024 | |
0.1.312-alpha01 | 109 | 5/29/2024 | |
0.1.311-alpha01 | 102 | 5/29/2024 | |
0.1.310-alpha01 | 73 | 5/29/2024 | |
0.1.309-alpha01 | 89 | 5/29/2024 | |
0.1.308-alpha01 | 87 | 5/29/2024 | |
0.1.307-alpha01 | 86 | 5/29/2024 | |
0.1.306-alpha01 | 92 | 5/29/2024 | |
0.1.305-alpha01 | 97 | 5/29/2024 | |
0.1.303-alpha01 | 102 | 5/29/2024 | |
0.1.302-alpha01 | 107 | 5/29/2024 | |
0.1.301-alpha01 | 94 | 5/29/2024 | |
0.1.300-alpha01 | 103 | 5/28/2024 | |
0.1.299-alpha01 | 93 | 5/28/2024 | |
0.1.298-alpha01 | 103 | 5/24/2024 | |
0.1.297-alpha01 | 98 | 5/24/2024 | |
0.1.296-alpha01 | 109 | 5/23/2024 | |
0.1.295-alpha01 | 93 | 5/23/2024 | |
0.1.294-alpha01 | 84 | 5/23/2024 | |
0.1.293-alpha01 | 108 | 5/21/2024 | |
0.1.292-alpha01 | 94 | 5/17/2024 | |
0.1.291-alpha01 | 109 | 5/17/2024 | |
0.1.290-alpha01 | 106 | 5/16/2024 | |
0.1.289-alpha01 | 104 | 5/16/2024 | |
0.1.288-alpha01 | 444 | 5/16/2024 | |
0.1.287-alpha01 | 120 | 5/15/2024 | |
0.1.286-alpha01 | 92 | 5/15/2024 | |
0.1.285-alpha01 | 86 | 5/15/2024 | |
0.1.284-alpha01 | 112 | 5/15/2024 | |
0.1.283-alpha01 | 90 | 5/15/2024 | |
0.1.282-alpha01 | 127 | 5/15/2024 | |
0.1.281-alpha01 | 107 | 5/15/2024 | |
0.1.280-alpha01 | 95 | 5/15/2024 | |
0.1.279-alpha01 | 99 | 5/15/2024 | |
0.1.278-alpha01 | 102 | 5/15/2024 | |
0.1.277-alpha01 | 95 | 5/15/2024 | |
0.1.276-alpha01 | 101 | 5/15/2024 | |
0.1.275-alpha01 | 93 | 5/15/2024 | |
0.1.274-alpha01 | 93 | 5/15/2024 | |
0.1.273-alpha01 | 81 | 5/15/2024 | |
0.1.272-alpha01 | 87 | 5/15/2024 | |
0.1.271-alpha01 | 113 | 5/14/2024 | |
0.1.270-alpha01 | 84 | 5/14/2024 | |
0.1.269-alpha01 | 103 | 5/14/2024 | |
0.1.267-alpha01 | 99 | 5/14/2024 | |
0.1.266-alpha01 | 92 | 5/14/2024 | |
0.1.265-alpha01 | 89 | 5/14/2024 | |
0.1.264-alpha01 | 87 | 5/14/2024 | |
0.1.263-alpha01 | 92 | 5/14/2024 | |
0.1.262-alpha01 | 109 | 5/14/2024 | |
0.1.261-alpha01 | 102 | 5/14/2024 | |
0.1.260-alpha01 | 106 | 5/14/2024 | |
0.1.259-alpha01 | 107 | 5/14/2024 | |
0.1.258-alpha01 | 102 | 5/14/2024 | |
0.1.257-alpha01 | 99 | 5/14/2024 | |
0.1.256-alpha01 | 97 | 5/14/2024 | |
0.1.255-alpha01 | 110 | 5/14/2024 | |
0.1.253-pullrequest0116-0276 | 98 | 5/14/2024 | |
0.1.253-pullrequest0116-0274 | 86 | 5/14/2024 | |
0.1.253-pullrequest0116-0273 | 71 | 5/14/2024 | |
0.1.253-alpha01 | 91 | 5/14/2024 | |
0.1.252-alpha01 | 111 | 5/13/2024 | |
0.1.251-alpha01 | 102 | 5/13/2024 | |
0.1.250-alpha01 | 92 | 5/13/2024 | |
0.1.249-alpha01 | 72 | 5/3/2024 | |
0.1.248-alpha01 | 141 | 4/24/2024 | |
0.1.247-alpha01 | 105 | 4/16/2024 | |
0.1.245-alpha01 | 99 | 4/16/2024 | |
0.1.244-alpha01 | 103 | 4/16/2024 | |
0.1.243-alpha01 | 103 | 4/16/2024 | |
0.1.240-alpha01 | 95 | 4/16/2024 | |
0.1.238-alpha01 | 94 | 4/16/2024 |