Compare two different versions of assertEquals()
Look at the definitions of assertEquals() in JUnit and TestNG respectively:
JUnit:
static void assertEquals(Java.lang.Object expected, java.lang.Object actual) static void assertEquals(java.lang.String message, java.lang.Object expected, java.lang.Object actual)
TestNG:
static void assertEquals(java.lang.Object actual, java.lang.Object expected) static void assertEquals(java.lang.Object actual, java.lang.Object expected, java.lang.String message)
Ignore the type of each parameter and do not consider it, re-view actual , expected, message The order of these three parameters:
The order in JUnit is: (message), expected, actual.
The order in TestNG is: actual, expected, (message).
The subtle difference is the order of actual (actual value) and expected (expected value), and its relative position to the other two parameters when message (information text) exists . In JUnit, message (if it exists) takes precedence, followed by expected, and then actual; in TestNG, it is exactly the opposite, actual takes precedence, followed by expected, and then message.
In comparison, I think TestNG's definition of assertEquals() is more in line with human thinking logic, which is the so-called "user friendliness". Of course, this is just a personal opinion, a matter of opinion.
When I first saw the definition of assertEquals() in JUnit, I was thinking, why isn't actual first and expected last? Today I saw TestNG's definition of assertEquals() for the first time, and suddenly I felt like "everyone sees the same thing". Of course, bringing this up now feels like an afterthought.
Based on this, I applaud TestNG!
The above is the comparison of two different versions of assertEquals(). For more related content, please pay attention to the PHP Chinese website (m.sbmmt.com)!