Is there any differences between those two?
IsTrue(Boolean, String) Tests whether the specified condition is true and throws an exception if the condition is false. IsTrue() Tests whether the specified condition is true and throws an exception if the condition is false.
Assertions are central to unit testing in any of the xUnit frameworks, and NUnit is no exception. NUnit provides a rich set of assertions as static methods of the Assert class. If an assertion fails, the method call does not return and an error is reported.
No difference. Assert.True()
and others (without Is
) were added since v2.5.
From documentation for the version 2.5
: (nunit v2.5)
Two forms are provided for the True, False, Null and NotNull conditions. The "Is" forms are compatible with earlier versions of the NUnit framework, while those without "Is" are provided for compatibility with NUnitLite
BTW, Disassembled nunit.framework.dll (using ILSPY)
public static void IsTrue(bool condition) { Assert.That(condition, Is.True, null, null); } public static void True(bool condition) { Assert.That(condition, Is.True, null, null); }
There does not seem to be any implementational difference. Looking at the source code for the most recent version here, the True
, IsTrue
and That
are all implemented in the same way when the argument lists are the same:
public static void True(bool condition, string message, params object[] args) { Assert.That(condition, Is.True, message, args); } ... public static void IsTrue(bool condition, string message, params object[] args) { Assert.That(condition, Is.True, message, args); } ... static public void That(bool condition, string message, params object[] args) { Assert.That(condition, Is.True, message, args); }
The overloaded methods are implemented analogously.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With