~/ 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/e17f6566-5fd0-4dc0-a6b0-8b23459362fb/flashcard utf-8 LF