xUnit v3 examples: Assert.Skip, TestContext & TheoryDataRow

xUnit 3 has been launched and including many features. These include assert methods for skipping tests, a new TestContext  and new ways of adding theory data to unit tests.

This code example will allow you to try out the features for yourself.

You can learn more about xUnit v3 features, or watch the video:

Download the code example

You'll need to fill out the code example form. We will send you an email where you can download the code example.

The code example will be in a zip file.

Software

This is the software that will need to be installed onto your machine.

How to run the unit tests

Open up RoundTheCode.XUnit3.sln in Visual Studio. Go to Test and Test Explorer in the top menu and run all the tests. They should all pass apart from the ones that are set up to skip.

In the RoundTheCode.XUnit3.UnitTests project, there is a test class for each of the features covered. These include:

  • SpeedConversionHelperSkipTests.cs - Skip assert methods
  • SpeedConversionHelperSkipAttributeTests.cs - Using Skip properties in the Fact attribute
  • SpeedConversionHelperTheoryDataRowTests.cs - The TheoryDataRow type
  • SpeedConversionHelperMatrixTheoryDataTests.cs - The MatrixTheoryData type
  • SpeedConversionHelperTestContextTests.cs - The TestContext instance