Mockito, Spy, PowerMock


Mockito Mocks vs. Spies Mock – bare-bones shell instance

Spy – wrap an existing instance

PowerMock final classes without interfaces static methods privates

Test-driven development: JUnit



Expected Exceptions Test

@RunWith BlockJUnit4ClassRunner – default junit runner SpringJUnit4ClassRunner allows you to use dependency injection in test classes or to create transactional test methods. MockitoJUnitRunner for automatic mock initialization. Suite Parameterized Parameters class

JUnit 5 – @ExtendWith

replace with


or your custom rule: […]

How to add lombok to your project

How to add lombok to your project build.gradle should looks like:

IntelliJ IDEA: Enable Annotation Processing should be checked Annotate class with your logger – @Slf4j // or: @Log @CommonsLog @Log4j @Log4j2 @XSlf4j

or create log4j2.xml

add dependencies

and use log4j2

over Slf4j facade: add dependency

  @Getter […]