Avoid creating unnecessary test data

12 Jul

This post is with respect to writing automated tests.

In my tenure, I’ve witnessed some people just take for granted or take for liberty the creation of unnecessary test data. They may be doing it:

  • as a precautionary measure in case it is needed, but again it’s “precautionary”.
  • don’t know that you could do without the test data, or didn’t comtemplate whether that test data is really needed or not, just assumed it would be needed.
  • because it’s the standard/normal happy path route to take and is “easy” to do when creating tests.

One case in point:

The application offers functionality that works anonymously, and offers functionality that requires a login. Some functionality overlap between the two (you can do it with our without login, but get some extra features when logged in). And now, say you want to run tests concurrently in parallel, like with Selenium Grid, etc. When login accounts come into play you either need to have enough accounts dedicated to each test so that you don’t have account conflicts (from any modifications to data relating to account) when tests are  executed concurrently. Or you create new test accounts on the fly for each tests.

Some people just take that generalization and have all tests create an account  & login as a precondition (test setup), regardless if the test really needed to do so or not (based on analyzing whether the feature being tested required a login or not). Granted storage is cheap these days that it might not matter, but sometimes it does, and in any case, extra test data is just extra garbage in the system. More work to have to have tasks/scripts purge the data, or more junk that gets added to system if not purged, plus more crapped logged in application/server logs and database transaction logs.

I follow the lean testing approach, please avoid creating unnecessary test data if your test doesn’t actually need it. Do an evaluation of whether your test needs to do things that create test data. Examples of unnecessary test data in some cases:

  • creating account logins
  • adding additional info to an test account when not needed or used (address, name, age, likes, preferences, etc.)
  • saving projects/data without deleting them after test when there is option to do so (from the application)
  • creating account to test new account creation but not deleting account after test when there is option to do so (from the application)
  • adding items to (shopping) cart but not removing them at end of test (when leaving them in cart keeps junk data in the system)
  • placing test orders to the system without cancelling them afterwards

One might generate unnecessary test data from manual testing too, and should avoid it. But unnecessary data from automated tests becomes a bigger problem due to frequency of test runs and how many tests get run (regression suite grows over time).

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Anastasia Writes

politics, engineering, parenting, relevant things over coffee.

One Software Tester

Trying To Make Sense Of The World, One Test At A Time

the morning paper

an interesting/influential/important paper from the world of CS every weekday morning, as selected by Adrian Colyer

RoboSim (Robot Simulator)

Visualize and Simulate the Robotics concepts such as Localization, Path Planning, P.I.D Controller


open notebook

a happy knockout mouse.

my journey into computer science

Perl 6 Advent Calendar

Something cool about Perl 6 every day


Inspire and spread the power of collaboration

Niraj Bhatt - Architect's Blog

Ruminations on .NET, Architecture & Design

Pete Zybrick

Bell Labs to Big Data

Seek Nuance

Python, technology, Seattle, careers, life, et cetera...


New Era of Test Automation

Der Flounder

Seldom updated, occasionally insightful.

The 4T - Trail, Tram, Trolley, Train

Exploring Portland with the 4T

Midnight Musings

Thoughts on making art

Automation Guide

The More You Learn The More You Play...!

The Performance Engineer



Thoughts related to software development

%d bloggers like this: