Using Mockito's InjectMocks

1 · Carlos Alexandro Becker · March 5, 2015, midnight
FYI: Like the previous post, this is a really quick tip. Let’s imagine we have two classes, and one depends on another: Another.java: @Log public class Another { public final void doSomething() { log.info("another service is working..."); } } One.java: @Log @RequiredArgsConstructor public class One { private final transient Another another; public final void work() { log.info("Some service is working"); another.doSomething(); log.info("Worked!"); } } Now, if we want to test One, we need an inst...