David
David

Reputation: 2566

Why is there no parameter for the fail message for Assert.NotNull in xUnit.net?

In constract to e.g. Assert.False where I can supply a message to be displayed when the assert fails, e.g. Assert.NotNull has only one overload that just takes the object to check. Is there a reason for it?

namespace Xunit
{
  public class Assert
  {
    // ...
    public static void False(bool condition, string userMessage);
    // ...
    public static void NotNull(object @object);
    // ...
  }
}

Upvotes: 6

Views: 3500

Answers (1)

Jonathan Allen
Jonathan Allen

Reputation: 70327

Dogma. They believe that you should never have more than one assertion per test, thus you don't need it.

The solution, if you otherwise like xUnit, is to download the source code for just the Assert module and paste it into your project. It is separate from everything else specifically so that you can tailor it to your needs.


Here is my version of said library with messages added: https://github.com/docevaad/Chain/tree/master/Tortuga.Chain/xTests.Tortuga.Chain.SqlServer.source/shared/Asserts

Upvotes: 9

Related Questions