java.lang.Object
me.sbasalaev.Assert
Assertions in code.
All methods throw
AssertionError if the corresponding tests fail.
To check the preconditions of methods and constructors where the exceptional
situation is the caller's fault for not following method contract use
Require instead. The method names are chosen so that Assert
class itself is imported rather than individual methods, e.g.
var list = List.of("A", "B", "C");
Assert.that(list.last().equals("C"));
- See Also:
-
Method Summary
-
Method Details
-
that
public static void that(boolean expression) Asserts givenexpressionis true.- Parameters:
expression- the expression to be checked.- Throws:
AssertionError- ifexpressionis false.
-
not
public static void not(boolean expression) Asserts givenexpressionis false.- Parameters:
expression- the expression to be checked.- Throws:
AssertionError- ifexpressionis true.
-
nonNull
Asserts givenvalueis notnull.- Type Parameters:
T- the type of the value.- Parameters:
value- the value to be checked.- Returns:
- the value if it is not
null. - Throws:
AssertionError- if thevalueisnull.- See Also:
-