The Assert methods in JUnit are all placed in the Assert class, summarizing the classification of the Assert methods in the JUnit class.
1. Asserttrue/false([String message,]boolean condition);
Determines whether a condition is true or false. Feel this is the best use, don't write down so many method name.
2.fail([String message,]);
Failed, can have messages, or no messages.
3.assertequals([String message,]object expected,object Actual);
You can specify an output error message if you want to determine equality.
The first parameter is the expected value, and the second argument is the actual one.
This method has multiple implementations for each variable. Basically the same in JDK1.5.
But the idea is to float and double the value of a delta at the back of the number.
4.assertnotequals([String message,]object expected,object Actual);
Determine if they are not equal.
The first parameter is the expected value, and the second argument is the actual one.
5.assertarrayequals([java.lang.String message,] java.lang.object[] expecteds, java.lang.object[] Actuals);
6.assertnotnull/null([String message,]object obj);
Interpret whether an object is non-empty (not empty).
7.assertsame/notsame([String message,]object expected,object Actual);
Determines whether two objects point to the same object. Look at the memory address.
8.failnotsame/failnotequals(String message, object expected, object actual)
Output error messages when they do not point to the same memory address or are not equal.
Note that the information is required, and the output is formatted.
9.assertthat(java.lang.String reason, java.lang.Object actual, Org.hamcrest.Matcher Matcher);
Where reason is the output information when the assertion fails, actual is the asserted value or object, Matcher is the assertion's match, and the logic inside determines that the given actual object is full of unsatisfied assertions.
(if needed is a jar package with assertthat needed to introduce JUNIT4 into the project, as well as Hamcrest-core.jar and Hamcrest-library.jar)
Summary of Assert methods in JUnit