Testing
33 → Testing
Previous: 32 Standard Libraries → Next: 34 Modules
▶️ mvn test -f pkg14testing/pom.xml
Why test?
| Type | Purpose |
|---|---|
| Unit | One class/method in isolation |
| Integration | Components together (DB, HTTP) |
| Property-based | Random inputs find edge cases |
Stack in this project
| Tool | Role |
|---|---|
| JUnit 5 | Test runner, assertions |
| Mockito | Mock dependencies |
| AssertJ | Fluent assertions |
| jqwik | Property-based testing |
1@Test2void add_twoPlusThree_isFive() {3 assertEquals(5, calculator.add(2, 3));4}5 6@Test7void findUser_notFound_returnsEmpty() {8 when(repo.findById(99)).thenReturn(Optional.empty());9 assertThat(service.find(99)).isEmpty();10}Related → Testing.md
Related → 14 Effective Java
Next → 34 Modules