~/ learn/ java-from-zero/ cards/ Testing with JUnit 5
1 of 4

Type a JUnit 5 test method with AAA structure

Type a JUnit 5 test method with AAA structure

Answer

@Test void add_returnsSum() { int result = calc.add(3, 4); assertEquals(7, result); }

@Test marks this as a test case. assertEquals(expected, actual) fails the test if the values differ. The method name describes the scenario — the test output reads like a specification.

space flip · ← → navigate · esc to exit
NORMAL ~/memra/library/9bf4ac62-e755-4d28-abb4-e97b84c794cb/flashcard utf-8 LF