1

I have an xUnit unit testing project. All was working fine in .NET 5.

In Visual Studio 2022, I changed the .NET Version in the csproj to .NET 6 as shown below.

enter image description here

Following this, the tests build but no longer run.

There is no info in the output window. The Test Explorer just says it wont run the tests, with 'unexpected error detected'.

enter image description here

What should I do to fix this?

1
  • xUnit works just fine. Make sure you upgrade to the latest packages for both xUnit and Microsoft.NET.Test.Sdk. You need to upgrade the Test SDK every time the runner, in this case Visual Studio, is upgraded. You'd run into the same problem if you kept working with .NET 5 in Visual Studio 2022 Nov 15, 2021 at 13:38

2 Answers 2

4

I created a new project and compared the csproj file with my old project. There were a couple of differences

First, I needed to add the nuget package for Microsoft.NET.Test.Sdk (in my case, version 16.11.0). This seemed to fix it.

I also noticed a couple of properties in the first PropertyGroup that I was missing. I added those too. However, just adding Microsoft.NET.Test.Sdk fixed it for me.

enter image description here

1
  • 3
    Nullable and IsPackable have nothing to do with testing. Nullable enables null checking during compilation. Nov 15, 2021 at 13:41
1

In my case I was changing from NUnit to XUnit and also needed to add the xunit.runner.visualstudio nuget package

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.