Concept
JUnit runs methods annotated with @Test and reports which assertions failed. Parameterised tests cover a table of cases, and assertThrows checks error paths.
The tutor works through these with you, in conversation and code. A session ends when you have shown them, not when a video does.
A few lines that show JUnit tests doing its job.
class MoneyTest {
@Test
void addsSameCurrency() {
var sum = new Money("USD", 100).plus(new Money("USD", 250));
assertEquals(350, sum.cents());
}
@ParameterizedTest
@ValueSource(longs = {-1, -100})
void rejectsNegativeAmounts(long cents) {
assertThrows(IllegalArgumentException.class, () -> new Money("USD", cents));
}
}Naming tests test1, test2, or after the method under test. When one fails, the name should say which behaviour broke: rejectsNegativeAmounts tells you; testPlus does not.
Your roadmap puts these before JUnit tests, unless you already know them.
Once a session shows you understand JUnit tests, it comes back for review. Each review takes a minute and tells the memory model how well you still know it.
Topics that build on JUnit tests.