Test Data Management Strategy

Toshiya Komoda
2 min readFeb 18, 2021

How do you manage test data in your unit tests or automated API tests ?

If you tests API with large input data, for example JSON, it eventually gets harder to manage test data as you add more test cases. Imagine, what happens when you have 1000+ test cases !

I think we have 2 common strategies for the test data management.

  1. Not share test data across test cases. It’s pretty simple strategy. Each test case has full set of test data independently. They may be managed in the separated files. Advantage of this approach is that there is a clear separation. So, adding new test case is pretty easy and it never get complicated even though you’ll have 1000+ test cases. However, drawback of this approach is also clear. There will be a loooooot of copy and paste. What happens if the API interface changs ? It is hard to add/change field values for all the test cases.
  2. Share the test data across test cases. To avoid the problem of copy and paste, you might think of re-using the test data. You prepare default test data, and each test case will override some of the field in the default. It should be easy to update the default data when API interface changes. Also, you can easily understand what the purpose of each test case by looking overridden values. Drawback of this approach is that when you need completely different data than default. You may end up to add another default dataset. Managing multiple default data and override hierarchy would be tedious.

Basically, I can’t say which is better. It depends. If variation of your test data is small, then “Share the test data” is better because you don’t need to have more than a couple of default data and override hierarchy won’t be complex. On the other hand, if you need more diverse set of test data, “Not share test data” will be more suitable.

--

--