mohit2978/Junit-Mockito

JUnit 5 & Mockito — unit testing, mocking, stubbing, ArgumentCaptor, @SpringBootTest, @WebMvcTest, @DataJpaTest | Applied in production at Samsung SDS

★ 0Forks 0GitHub ↗Compare
backendjavajunitjunit5mockitospringtddtestingunittesting

README

🧪 JUnit & Mockito — Testing Notes

Hands-on notes and practice code for unit testing Java applications using JUnit 5 and Mockito. Applied directly in production at Samsung SDS.

📚 Topics Covered

JUnit 5

  • Test lifecycle annotations (@BeforeEach, @AfterEach, @BeforeAll)
  • Assertions — assertEquals, assertThrows, assertAll
  • Parameterized tests
  • Test ordering and conditional execution

Mockito

  • Mocking & stubbing with @Mock, @InjectMocks
  • Argument matchers
  • Verifying interactions — verify(), times(), never()
  • Spy vs Mock
  • Capturing arguments with ArgumentCaptor
  • Mocking void methods — doNothing, doThrow

Testing Patterns

  • Service layer unit testing
  • Repository layer testing with @DataJpaTest
  • Controller layer testing with @WebMvcTest
  • Integration testing with @SpringBootTest

🛠️ Tech Stack

Java JUnit Mockito Spring Boot

👨‍💻 About Me

Mohit Kumar — Software Engineer @ Samsung SDS NIT Allahabad M.Tech | GATE 2020 — 98.68 percentile

LinkedIn GitHub

Contributors

mohit2978

Issues