Tag: testing

Getting Real-World Test Data from Production

Why? To responsibly test changes before deploying them to production, we need a test environment that behaves, in as many aspects as possible, the same way as our production environment does. Integration tests should be running in an environment that is as close to production as possible. We want the ability to reproduce production issues […]

Suppressing Static Initializers with Mockito + Powermock

Often as developers, we need to add unit testing to legacy code while being unable to make non-trivial changes to the code under test. In legacy code, logging and other resources are often set up in a static initializer. That code won’t execute nicely in a unit testing environment (could be using JNDI or something […]

Testing vs. Alerting Part I

If you want to evaluate a testing plan, you must also consider your alerting plan. Alerting and testing are complimentary, both serve to identify defects. Testing typically serves to identify defects before code is deployed to production, while alerting typically notifies developers of an issue with a running system. You need to consider both testing […]

Mocking Static Singletons in Java (Mockito 3.4+, EasyMock, JMockit)

A common problem for Java developers that wish to get comprehensive unit test coverage is handling the mocking of singletons that are implemented using static method calls. Let’s look at how we can mock singleton behavior using three common Java testing libraries Mockito, EasyMock and JMockit. Part 1: Write Code to Test To start with, […]