I was writing some stuff that programmatically executed terraform via Hashicorp's terraform-exec library this week. This works by interacting with a terraform executable that you provide (along with a working directory) to the NewTerraform constructor. Here's the trick: when testing this code it does not need to interact with the real executable. It can subprocess… Continue reading How to Test Code that Executes Subprocesses
Category: Testing
Test Setup and Teardown Methods in Go
Building Your Own (JavaScript) Test Doubles
A test double is an object or function that behaves like a real piece of code, but is, instead, solely for a test. It mimics the functionality of something, without being that something. There are plenty of frameworks to deal with test doubles in JavaScript (like sinon), but it's helpful to the various types of… Continue reading Building Your Own (JavaScript) Test Doubles
What to Put in Test Docblocks
There's a great article on dockblocks in tests that has some really good advice. Sometimetimes a good test name isn't enough and there should be some more context. Here are some other things I like to put in PHPUnit test docblocks. For Bugs & Bug Fixes In other words, I like to put the bug… Continue reading What to Put in Test Docblocks
Improving Tests One Name at a Time
Let's take a look at a simple object and a typical test. The code examples here are PHP, but this advice applies to any language or testing framework. Looks great right? I would argue that the test, while valid, is not as useful as it could be because the name of the test is terrible.… Continue reading Improving Tests One Name at a Time

