How To Test Your Tests

SMPTE_Color_Bars1_zpsda846084
When we write tests, we focus on the scenario we want to test, and then write that test.

Pretty simple, right?

That’s how our minds work. We can’t focus on many things at the same time. TDD acknowledges that and its incremental nature is built around it.

TDD or not, when we have a passing test, we should do an evaluation.

Start with this table:

PropertyDescription
ValidityDoes it test a valid scenario? Is this scenario always valid?
ReadabilityOf course I understand the test now, but will someone else understand the test a year from now?
SpeedHow quickly does it run? Will it slow down an entire suite?
AccuracyWhen it fails, can I easily find the problem is in the code, or do I need to debug?
DifferentiationHow is this case different than its brothers? Can I understand just by looking at the tests?
MaintenanceHow much work will I need to do around this test when requirements change? How fragile is it?
FootprintDoes the test clean after itself? Or does it leave files, registry handles, threads, or a memory blob that can affect other tests?
RobustnessHow easy it is to break this test? What kind of variation are we permitting, and is that variation allowed?
DeterministicDoes this test have dependencies (the computer clock, CPU, files, data) that can alter its result based on when or where it runs?
IsolationDoes the test rely on a state that was not specified explicitly in it? If not, will the implicit state always be true?

If something’s not up to your standards (I’m assuming you’re a high standard professional) fix it.

Now, I hear you asking: Do all this for every test?

Let’s put it this way: If the test fails the evaluation, there’s going to be work later to fix it. When would you rather do it – now, when the test is fresh in your head, or later, when you have to dive in again, into code that you haven’t seen in 6 months, instead of working on the new exciting feature you want to work on?

It’s testing economics 101. Do it now.

Reference: How To Test Your Tests from our JCG partner Gil Zilberfeld at the Geek Out of Water blog.

Do you want to know how to develop your skillset to become a Java Rockstar?

Subscribe to our newsletter to start Rocking right now!

To get you started we give you two of our best selling eBooks for FREE!

JPA Mini Book

Learn how to leverage the power of JPA in order to create robust and flexible Java applications. With this Mini Book, you will get introduced to JPA and smoothly transition to more advanced concepts.

JVM Troubleshooting Guide

The Java virtual machine is really the foundation of any Java EE platform. Learn how to master it with this advanced guide!

Given email address is already subscribed, thank you!
Oops. Something went wrong. Please try again later.
Please provide a valid email address.
Thank you, your sign-up request was successful! Please check your e-mail inbox.
Please complete the CAPTCHA.
Please fill in the required fields.

Leave a Reply


seven × 6 =



Java Code Geeks and all content copyright © 2010-2014, Exelixis Media Ltd | Terms of Use | Privacy Policy | Contact
All trademarks and registered trademarks appearing on Java Code Geeks are the property of their respective owners.
Java is a trademark or registered trademark of Oracle Corporation in the United States and other countries.
Java Code Geeks is not connected to Oracle Corporation and is not sponsored by Oracle Corporation.
Do you want to know how to develop your skillset and become a ...
Java Rockstar?

Subscribe to our newsletter to start Rocking right now!

To get you started we give you two of our best selling eBooks for FREE!

Get ready to Rock!
You can download the complementary eBooks using the links below:
Close