This website uses cookies to ensure you get the best possible experience. See our Cookies Policy.

PMG Digital Made for Humans

When Green Tests Fail

2 MINUTE READ | May 29, 2014

When Green Tests Fail

Test Driven Development has a what’s called a red (failing) green (passing) refactor cycle. You start with a failing testing, writing a basic behavior specification for some bit of code that doesn’t exist yet. Then you write the just enough code to make your test pass. Then you change the test to reflect new functionality that will be added to the code and refactor the code to make the test pass. Repeat ad infinitum.

Even if you don’t do test-first development, this red green refactor cycle is addictive. Instant feedback that your code works! My tests are green! Let’s ship it. Not so fast.

This is the concept of, as Kent Beck put it, test fidelity. If all tests pass and we deploy the code, sometimes stuff just isn’t going to work. It’s possible that this failure is a solvable issue: a difference between a development and production environment is solvable, for instance. Integration tests failing to cover the seams between components would be another easily solvable case.

Sometimes those failures are not so solvable. Sometimes they are things tests could not have caught. Maybe a user does something unexpected and breaks your application. Maybe the scale of datasets in a production database doesn’t agree with your algorithm that worked on 5,000 records.

This is why having someone else there to try and break your code is valuable. It’s why business oriented logging is valuable and it’s one of the main reasons QA people have gigs.

Every time any person or thing interacts with your code it’s the result is feedback on whether that code works or doesn’t. That’s a huge opportunity for any developer to get better.

It’s okay to have confidence in code’s quality and utility based on tests. But be sure to realize that sometimes green tests fail to give you the proper feedback. Seek it elsewhere.

Stay in touch

Bringing news to you

Subscribe to our newsletter

Photo by wetwebwork.

Posted by Christopher Davis

Related Content

thumbnail image

Get Informed

PMG Innovation Challenge Inspires New Alli Technology Solutions

4 MINUTES READ | November 2, 2021

Get Informed

Applying Function Options to Domain Entities in Go

11 MINUTES READ | October 21, 2019

thumbnail image

Get Informed

My Experience Teaching Through Jupyter Notebooks

4 MINUTES READ | September 21, 2019

Get Informed

Trading Symfony’s Form Component for Data Transfer Objects

8 MINUTES READ | September 3, 2019

Get Inspired

Working with an Automation Mindset

5 MINUTES READ | August 22, 2019

Get Informed

Parsing Redshift Logs to Understand Data Usage

7 MINUTES READ | May 6, 2019

Get Inspired

3 Tips for Showing Value in the Tech You Build

5 MINUTES READ | April 24, 2019

thumbnail image

Get Informed

Testing React

13 MINUTES READ | March 12, 2019

Get Inspired

Tips for Designing & Testing Software Without a UX Specialist

4 MINUTES READ | March 6, 2019

Get Informed

A Beginner’s Experience with Terraform

4 MINUTES READ | December 20, 2018