13 September 2025

#Mockito

#Mockito
Topic - SubTopic Basic Intermediate Advanced Expert
Mockito Basics - Overview What is Mockito?, Features of Mockito, Difference between Mockito and other mocking frameworks Mockito architecture, Mock vs Spy, Why use mocking Mockito vs PowerMockito, Use cases for unit testing, Integration with JUnit Enterprise-level mocking strategies, Multi-module testing, Designing testable code with Mockito
Mocking & Spying Creating mocks, Basic stubbing, Verifying method calls Spy objects, Partial mocking, Argument matchers Mocking final classes, Mocking static methods (PowerMockito), Custom answers Complex stubbing, Chained method mocking, Performance considerations for mocks
Annotations & Setup @Mock, @Spy, @InjectMocks, @Captor MockitoAnnotations.openMocks(), initMocks(), Field injection Annotation-based vs programmatic mocking, Constructor injection Advanced test setup patterns, Dependency injection for large modules, Integration with Spring Boot tests
Verification & Behavior verify() basics, verifyZeroInteractions, verifyNoMoreInteractions Times verification, InOrder verification, AtLeast/AtMost checks Verifying private methods, Complex interaction verification Verifying multi-threaded code, Asynchronous call verification, Global interaction strategies
Stubbing & Argument Matchers when().thenReturn(), thenThrow(), thenAnswer() ArgumentMatchers.any(), eq(), refEq() Custom argument matchers, Answer interface, Dynamic stubbing Advanced conditional stubbing, Context-aware answers, Complex return sequences
Exceptions & Timeouts Stubbing exceptions, verify exceptions, Timeout verification doThrow(), doAnswer(), doReturn() Handling asynchronous exceptions, Mockito with CompletableFuture Exception handling patterns in complex tests, High-concurrency testing
Mockito with JUnit JUnit 4 vs JUnit 5 integration, Basic test case structure @RunWith(MockitoJUnitRunner.class), MockitoExtension, Nested tests Parameterized tests, Combining multiple extensions, Test lifecycle management Advanced integration with Spring Boot, Testcontainers, Multi-module test suites
Behavior Driven Testing BDDMockito basics, given/when/then syntax Combining BDDMockito with JUnit, Verification in BDD style Advanced BDD scenarios, Custom BDD answers Enterprise-level BDD testing strategies, Integrating BDD with CI/CD pipelines
Advanced Features N/A Captors (@Captor), Resetting mocks, Clearing invocations Deep stubs, Mocking collections, Mocking generic types Optimizing large test suites, Multi-threaded mocks, Custom mock frameworks
Tools & Ecosystem N/A Integration with AssertJ, Hamcrest, Basic IDE setup Mockito with Spring Boot, Mockito with PowerMockito, Test coverage tools Enterprise testing strategies, Scaling Mockito tests for microservices, CI/CD automation for tests

Basic

Mockito Basics

  1. What is Mockito?
  2. Features of Mockito
  3. Difference between Mockito and other mocking frameworks
  4. Why is mocking important in unit testing?
  5. What are mocks and stubs?
  6. What is a spy in Mockito?
  7. Difference between mock and spy
  8. How to create a mock object?
  9. How to create a spy object?
  10. Explain basic stubbing
  11. Difference between thenReturn() and thenThrow()
  12. What is verify() in Mockito?
  13. verifyZeroInteractions() usage
  14. verifyNoMoreInteractions() usage
  15. Difference between mock() and Mockito.mock()
  16. How to use Mockito with JUnit?
  17. Difference between Mockito 1.x and 2.x
  18. What are ArgumentMatchers?
  19. Usage of eq() matcher
  20. Usage of any() matcher
  21. Usage of refEq() matcher
  22. What is the difference between @Mock and @Spy?
  23. What is @InjectMocks annotation?
  24. What is @Captor annotation?
  25. How to initialize mocks using MockitoAnnotations?
  26. What is initMocks() method?
  27. How to use openMocks() method?
  28. Difference between annotation-based and programmatic mocks
  29. How to reset a mock?
  30. Difference between doReturn() and when().thenReturn()
  31. What is default behavior of unstubbed mocks?
  32. How to check method call count?
  33. Difference between times(1) and atLeast(1)
  34. Difference between inOrder() and normal verify
  35. What is BDDMockito?
  36. given().willReturn() usage
  37. How to use thenAnswer()?
  38. Difference between thenReturn() and thenAnswer()
  39. Can you mock final classes?
  40. Can you mock static methods?
  41. Difference between Mockito and PowerMockito
  42. How to test exceptions using Mockito?
  43. Usage of doThrow()
  44. doAnswer() usage
  45. How to mock void methods?
  46. What is timeout verification?
  47. Difference between doNothing() and doThrow()
  48. How to use multiple stubbing?
  49. How to clear invocations of a mock?
  50. How to debug failing Mockito tests?

Intermediate

Mockito Setup & Verification

  1. @RunWith(MockitoJUnitRunner.class) usage
  2. MockitoExtension in JUnit 5
  3. Difference between JUnit 4 and JUnit 5 integration
  4. Nested test classes with Mockito
  5. Verifying method calls order
  6. InOrder verification basics
  7. AtLeast and AtMost verification
  8. verifyNoInteractions() usage
  9. verifyNoMoreInteractions() usage
  10. Resetting mocks in tests
  11. Capturing arguments using @Captor
  12. ArgumentCaptor usage
  13. Using Mockito with AssertJ
  14. Using Mockito with Hamcrest
  15. Combining multiple extensions
  16. Difference between field injection and constructor injection
  17. Using @InjectMocks for nested dependencies
  18. Difference between spy() and partial mock
  19. Capturing arguments in spy
  20. Mocking interfaces
  21. Mocking abstract classes
  22. Mocking generic types
  23. Mocking collections
  24. Mocking void methods
  25. Mocking exceptions
  26. Mocking multiple method calls
  27. Using doReturn() vs when().thenReturn()
  28. Verifying asynchronous calls
  29. Using timeout() for async methods
  30. Difference between doAnswer() and thenAnswer()
  31. Custom answers with Answer interface
  32. Chained stubbing
  33. Sequential stubbing
  34. Default answer behavior
  35. Stubbing with lambda expressions
  36. BDDMockito given/when/then syntax
  37. Differences between BDDMockito and standard Mockito
  38. Parameterized tests with Mockito
  39. Mocking final classes with Mockito 2+
  40. Using Mockito with Spring Boot
  41. Using Mockito with TestNG
  42. Using Mockito with Testcontainers
  43. Handling null values in mocks
  44. Argument matchers with null
  45. Mixing matchers and raw values
  46. verifyZeroInteractions() vs verifyNoInteractions()
  47. Checking invocation count with times()
  48. Checking invocation count with atLeastOnce()
  49. Checking invocation count with atMostOnce()
  50. Resetting mocks between tests

Advanced

Mockito Advanced Features

  1. Deep stubs usage
  2. Mocking chained method calls
  3. Mocking private methods (PowerMockito)
  4. Mocking static methods (PowerMockito)
  5. Mocking final methods (Mockito 2+)
  6. Mocking constructors (PowerMockito)
  7. Capturing return values from spy
  8. Mocking collection behavior
  9. Handling exceptions in chained calls
  10. Mocking generic return types
  11. Mocking generic arguments
  12. Custom argument matchers
  13. Dynamic answers with Answer interface
  14. Verifying complex interactions
  15. Interaction-based testing
  16. Behavior-driven development with Mockito
  17. Combining mocks and spies
  18. Using @InjectMocks with nested objects
  19. Constructor injection for nested dependencies
  20. Partial mocks with spy()
  21. Resetting spies
  22. Mixing mocks and real objects
  23. Mocking system classes
  24. Mocking third-party libraries
  25. Mocking web service clients
  26. Mocking database interactions
  27. Mocking repository calls
  28. Using doAnswer() for callbacks
  29. Mocking async services
  30. Verifying asynchronous invocations
  31. Multi-threaded test verification
  32. Using timeout verification with async code
  33. Verifying order of multi-threaded calls
  34. Mocking void methods with exceptions
  35. Mockito best practices for large projects
  36. Using Mockito with dependency injection frameworks
  37. Integration testing with Mockito
  38. Mockito limitations
  39. Mocking enums
  40. Mocking inner classes
  41. Mocking nested static classes
  42. Mocking generic collections
  43. Handling varargs in mocks
  44. Mixing @Mock and programmatic mocks
  45. Resetting mocks selectively
  46. Combining multiple stubbing approaches
  47. Mockito in CI/CD pipelines
  48. Mockito test maintainability
  49. Performance considerations for large test suites
  50. Advanced debugging strategies in Mockito

Expert

Mockito Enterprise & Optimization

  1. Designing testable architecture with Mockito
  2. Scaling Mockito tests for large codebases
  3. Multi-module project mocking
  4. Mockito with microservices
  5. Mockito with Spring Boot integration tests
  6. Using Mockito i

No comments:

Post a Comment

Most views on this month

Popular Posts