Tag: With cells JUnit implementation false dataset exp Core definition
Copy a little something from someone else's blog.
Original address: http://blog.csdn.net/wangpeng047/article/details/9628449
Assertions are the core implementation of writing test cases, that is, what the expected value is, and how much is the result of the test to determine whether the test passed.
Assertion Core Method
See if two arrays are equal.
assertarrayequals (expecteds, actuals) |
assertequals (expected, actual) |
to see if two objects are equal. The Equals () method, similar to string comparisons, |
assertnotequals (first, second) |
to see whether two objects are not equal. |
assertnull (object) |
to see if the object is empty. |
assertnotnull (object) |
to see if the object is not empty. |
assertsame (expected, actual) |
to see whether references to two objects are equal. Similar to using "= =" to compare two objects |
assertnotsame (Unexpected, actual) |
to see whether references to two objects are not equal. Similar to using "! =" to compare two objects |
asserttrue (condition) |
to see if the run result is true. |
assertfalse (condition) |
to see if the run result is false. |
assertthat (Actual, matcher) |
See if the actual value meets the specified condition |
fail () |
let test fail |
Annotations
@Before |
Initialize method |
@After |
Freeing resources |
@Test |
Test method, where you can test for expected exceptions and time-outs |
@Ignore |
Ignored test methods |
@BeforeClass |
For all tests, execute only once and must be static void |
@AfterClass |
For all tests, execute only once and must be static void |
@RunWith |
Specifies that a test class uses a runner |
@Parameters |
To specify a test data collection for a test class |
@Rule |
Allows flexibility to add or redefine the behavior of each test method in a test class |
@FixMethodOrder |
Specify the order in which test methods are executed |
A Test class unit test is executed in the following order:
@BeforeClass –> @Before –> @Test –> @After –> @AfterClass
The order in which each test method is called is:
@Before –> @Test –> @After
JUnit Framework uses (4)--junit common assertions and annotations