Skip to content
Hot News
Partialoverflow
Effective Unit Tests
Introduction
Item 1: Avoid Coding to Coverage
Item 2: Use exact matching where possible for mock setups
Item 3: Use argument captors for mock setups when exact matching is not possible
Item 4: Use test constants to assert expected field values
Item 5: Use @BeforeEach to set up class level test objects
Item 6: Cover all scenarios
Item 7: Make sure the test packages match the production code packages
Item 8: Don’t reference production constants in tests
Item 9: Static mocking and utility classes in dependency injection frameworks
Item 10: A discussion on lenient mocking, strict mocking and verifications
Item 11: Consider using more human readable unit test names
Item 12: Use PIT mutation testing
Effective Unit Tests
Effective Unit Tests
Introduction
Item 1: Avoid Coding to Coverage
Item 2: Use exact matching where possible for mock setups
Item 3: Use argument captors for mock setups when exact matching is not possible
Item 4: Use test constants to assert expected field values
Item 5: Use @BeforeEach to set up class level test objects
Item 6: Cover all scenarios
Item 7: Make sure the test packages match the production code packages
Item 8: Don’t reference production constants in tests
Item 9: Static mocking and utility classes in dependency injection frameworks
Item 10: A discussion on lenient mocking, strict mocking and verifications
Item 11: Consider using more human readable unit test names
Item 12: Use PIT mutation testing
Search for:
Search
Sunday, December 7, 2025