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).