JUnit v5 (Jupiter)
An Introduction |
Prof. David Bernstein
|
Computer Science Department |
bernstdh@jmu.edu |
import
statements@Test
)assert___()
methodsassert___()
MethodsAssertions.assertEquals(expected, actual [, description] )
Assertions.assertEquals(expected, actual, tolerance [, description] )
Assertions.assertArrayEquals( expected, actual [, tolerance] [,description])
Assertions.assertTrue(actual [, description])
Assertions.assertFalse(actual [, description])
assert___()
Methods (cont.)Assertions.assertSame(expected, actual [, description] )
Assertions.assertNull(actual [, description])
Atom
public int getAtomicNumber()
public boolean equals(Atom other)
assertThrows()
methodAtom
constructorIllegalArgumentException
if either of the parameters are negativeassert___()
invocations
after the exception will be thrown@BeforeEach
annotation to indicate that
the method should be invoked before every test method
and the @AfterEach
annotation to indicate that
the method should be invoked after every test method
org.junit.jupiter.api.BeforeEach
and/or org.junit.jupiter.api.AfterEach
@BeforeEach
or
@AfterEach
will be invoked
before/after every test methodassert___()
methods are often called
assertions, but they should not be confused with
assert
statements in Java
assert___()
method
can be thought of as an individual test.jar
files in the CLASSPATH
and execute a "test
runner" (commonly
org.junit.platform.console.ConsoleLauncher
)
passing it the name of the test class