Blog Archives

Mockito Chaining

Dynamic mocks are great. I believe it was Martin Fowler who first switched me onto them. What we should be testing is how an object interacts with its surroundings. Often this means setting it running and verifying that it made

Tagged with: , ,
Posted in Uncategorized

Log4j2 Mocking with Mockito and JUnit

This is an update to the very helpful work done here. I too have needed to put my own appender into a unit test so I can see that the right things are being logged. Depending on the logging framework

Tagged with: , ,
Posted in Uncategorized

Java Mockito and Mocking a Callback

It looks hard to mock something like this: The code above is a bit tricky to mock. It would be easy if it were In this case, the interface which has the doSomething function in it could be easily mocked

Tagged with: , ,
Posted in Uncategorized