Unit Testing with JUnit — a practical guide to Java JUnit with clear examples you can reuse in real projects.
Java Tutorial Series (82/90). Prefer one article? Read the complete Java tutorial.
Short description
Tests document behavior and catch regressions. Keep them fast and focused.
JUnit 5 test
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
class MathTest {
@Test
void addsNumbers() {
assertEquals(5, 2 + 3);
}
}