.NET
You NEED to Update Your Tests in .NET
xUnit v3 is available, and it’s listed as a separate package (not just an upgrade) called xunit.v3.
- Templates.
dotnet new xunit3
will create a new testing project. The output is an EXE which means you can run tests from the console. It also hasxunit.runner.json
to configure the execution of your tests. - Microsoft Testing Platform. To enable this, uncomment sections in the .csproj file. If you’re using JetBrains Rider, you’ll need to enable this feature otherwise Rider won’t detect the tests. (Warning: This platform is still new and has bugs.)
- Test pipeline startup. This allows you to execute code before the test runner starts discovering tests and also execute code after the tests have been run.
- Assembly fixtures. (Recall that a test fixture is a context that can be shared with other tests. Tests that use fixtures do not run in parallel.) xUnit v3 can now share a single instance of a fixture among all the test classes in your test assembly.
- Skip. You can skip tests individually or when a condition is met. This can be done inside the test or in the method’s attribute.
- Set culture. This is now settable in the xunit.runner.json file.
- Text context access. This gives you access to the metadata about the tests, mostly used when writing extensions.
- Test cancellation token. You can pass a token used by the test runner rather than making one from scratch.
- Theory data row. This data provider is now strongly typed instead of being
object[]
.