Search code examples
c#unit-testingxunit

Basic Assert in xUnit


Looking for a basic assert in xUnit. This is simple in MSTest and NUnit.

Assert.Fail("some message"); // MSTest - works
Assert.Fail("some message"); // NUnit - works (same syntax)
Assert.Fail("some message"); // xUnit - does not compile

The project is a C# xUnit Test Project (.NET Core) in Visual Studio 2019.

UPDATE

Responding to comments about what version of xUnit is installed. The NuGet package was installed automatically by Visual Studio when the project was created. The .csproj file reveals that Visual Studio installed version "2.4.0".


Solution

  • In XUnit assert message is a parameter. It is part of all Assert Extension Methods.

    For example :

    Assert.False(true, "true will never be false")