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 […]
Author: Sam French
Extract Method and Inline Variable in IntelliJ
Introduction This blog post will show, using videos, how to perform basic refactorings in IntelliJ. I’m using the IntelliJ 2020 community edition and OBS Studio to create these videos. The philosophy contained in these articles will largely be drawing from my favorite book on refactoring: Refactoring: Improving the Design of Existing Code by Martin Fowler. […]
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 […]
dependencyManagement tag in Maven
One very peculiar issue I’ve run into during development is an issue where I have a parent pom.xml file and a child pom.xml file. The child pom.xml file imports the parent artifact as a dependency. Now, when we make changes to dependencies in the parent pom.xml file, we don’t see them reflected when building the […]
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, […]
package.json scripts
When using npm (commonly with nodejs), we can pre-define command line commands in the package.json file, using the scripts option. Use Case: Pre-Standardized Commands Per Organization Description: Allow teams to standardize commands to allow easy cross-project development and collaboration. In our example, we will standardize a command extended-test that should be run by all developers […]