Where are my xUnit tests?

Lately, I am doing more .NET related work on MacOS. Visual Studio Code + .NET Core 2.0 are proving to be an awesome development experience.

Cross-platform .NET development does have its challenges. Take this error for instance:

No test is available in "my cool project". Make sure that test discoverer & executors are registered and platform & framework version settings are appropriate and try again.

What... is this?

My tests annotated with Fact attributes.

public async Task ShouldContainHeaderKey()
    //...stuff happens.

My project file has the appropriate package references (I think...).

  <PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.5.0" />
  <PackageReference Include="xunit" Version="2.3.1" />

  <DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.0" />
  <DotNetCliToolReference Include="dotnet-xunit" Version="2.3.1" />

Even using xunit command directly from Terminal works as expected.

$ dotnet xunit

However, this does not work.

$ dotnet test


Apparently, I did not include the xunit.runner.visualstudio package. This appears to be a requirement, even on MacOS.


$ dotnet add package xunit.runner.visualstudio

This fixes the issue; however, I wish I get the last four hours back.


Show Comments