Hands-on notes and practice code for unit testing Java applications using JUnit 5 and Mockito. Applied directly in production at Samsung SDS.
- Test lifecycle annotations (@BeforeEach, @AfterEach, @BeforeAll)
- Assertions — assertEquals, assertThrows, assertAll
- Parameterized tests
- Test ordering and conditional execution
- Mocking & stubbing with @Mock, @InjectMocks
- Argument matchers
- Verifying interactions — verify(), times(), never()
- Spy vs Mock
- Capturing arguments with ArgumentCaptor
- Mocking void methods — doNothing, doThrow
- Service layer unit testing
- Repository layer testing with @DataJpaTest
- Controller layer testing with @WebMvcTest
- Integration testing with @SpringBootTest
Mohit Kumar — Software Engineer @ Samsung SDS NIT Allahabad M.Tech | GATE 2020 — 98.68 percentile