Skip to content

Latest commit

 

History

6 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

Test Lab

This repository is focused on learning and practicing Mockito and JUnit, two of the most popular Java frameworks for unit testing and mocking. It includes many examples covering both basic concepts and more advanced testing scenarios.

Topics Covered

JUnit

  • Need for Unit Testing
  • Setting up a JUnit Test
  • Understanding assertEquals, assertTrue, and assertFalse
  • Using @Before, @After, @BeforeClass, and @AfterClass
  • Array Comparison in Tests
  • Testing Exceptions and Performance
  • Parameterized Tests
  • Organizing Tests into Suites

Mockito

  • Setting up JUnit and Mockito
  • Mocks vs. Stubs
  • Basic Mocking with Mockito
  • Variations in Stubbing (return values, argument matchers, exceptions)
  • Introduction to BDD Syntax
  • Verifying Mock Interactions and Call Counts
  • Capturing Arguments with Mocks
  • Using Hamcrest Matchers
  • Mockito Annotations (@Mock, @InjectMocks, @Captor)
  • JUnit Rules with Mockito
  • Real-World Example with Spring
  • Using Spies with Mockito
  • Limitations: Final and Private Methods
  • PowerMock with Mockito for Static and Private Methods, Constructors
  • Creating Effective Unit Tests

Each topic is represented by one or more tests, organized to make exploring each concept easy.

About

A collection of examples for learning unit testing and mocking in Java with JUnit and Mockito

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages