Xunit Tests Won’t Run After Upgrade to .Net 6

February 06, 2022

Some time ago, while trying to get .Net Core 3.1 to work with Xunit, I discovered that 2.4.1 was the correct library to use for xunit.runner.visualstudio. At the time, I wasn’t sure why this was the case.

Recently, after upgrading an Azure Function to .Net 6 from 5, I came across almost the reverse problem. It turns out that 2.4.3 actually works fine for xunit.runner.visualstudio, however, you need to include the following library as well:

Microsoft.NET.Test.Sdk

For .Net 6, if you want to run Xunit, then you need the following libraries:

<ItemGroup>

	<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />

	<PackageReference Include="xunit" Version="2.4.1" />
	<PackageReference Include="xunit.runner.console" Version="2.4.1" />
	<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3" />
</ItemGroup>

References

https://stackoverflow.com/questions/69972184/xunit-tests-no-longer-working-after-upgrade-from-net-5-to-net-6-q-a



Profile picture

A blog about one man's journey through code… and some pictures of the Peak District
Twitter

© Paul Michaels 2024