I did a Java Integration Test, so I'll output it so I don't forget it.
According to the official Oracle documentation
Assertions are statements in the Java programming language that allow you to test assumptions about a program.
Assertions are ** always Boolean type **, and we will test on the assumption ** true **. If false, throw ** AssertionError **.
In addition, the degree to which the function is covered by the test is called ** coverage **. The higher the quality of ** coverage **, the less bugs.
assertEqual() Determine if the expected and actual results are the same
EqualIntegrationTest.java
/**
* expected:Expected value
* actual:Actual value
* message:message(Displayed when the expected value and the actual value do not match)
*/
Assert.assertEqual(expected, actual);
Assert.assertEqual(message, expected, actual);
assertTrue() Determine if the given conditions are correct
TrueIntegrationTest.java
/**
* actual:Actual value
* message:message(Display if the given conditions are incorrect)
*/
Assert.assertTrue(expected > 1);
Assert.assertTrue(message, expected > 1);
assertNotNull() Determine if the given Object is not null
NotNullIntegrationTest.java
/**
* object:Expected value
* message:message(Displayed when object is null)
*/
Assert.assertNotNull(object);
Assert.assertNotNull(message, object);
assertNull() Determine if the given Object is null
NullIntegrationTest.java
/**
* object:Expected value
* message:message(Show if object is not null)
*/
Assert.assertNull(object);
Assert.assertNull(message, object);
assertSame() Determine if two given Objects refer to the same Object
SameIntegrationTest.java
/**
* expectedObject:Expected value
* actualObject:Actual value
* message:message(Show if object is not null)
*/
Assert.assertSame(expectedObject, actualObject);
Assert.assertSame(message, expectedObject, actualObject);
assertThat() It's basically a comparison, but its usage is wide-ranging Details
Recommended Posts