What is Test Data in Software Testing?
Data required to satisfy the prerequisites of test cases is called test data. You can manually create test data, use data generation tools, or import data from your production system.
Why use Test Data?
The primary purpose of test data is to improve productivity. If test data is already ready before executing a test case, the tester doesn't have to perform steps creating the data, thus saving time. Some non-functional testing types, like performance testing or security testing, require massive amounts of data, which is impossible to create manually.
The secondary purpose of test data is to avoid errors during testing. If a test case requires a large setup, the tester can make mistakes and render the test case useless. For instance, while testing authorization in security testing, you should always use test data. The test case steps should be something like:
- It should be possible for user U to do A, B, and C.
- It should not be possible for user U to do X, Y, and Z.
If we include creating and setting up security for user U in the steps, a small error can result in the test case failing (or passing) and missing its objective.
5 Tips on Preparing Test Data
Using test data can be messy and chaotic if not done correctly. Here are some tips to help you get the best out of your test cases with optimum test data:
1. Use one dataset per functionality.
To minimize the amount of test data, use the same data for all test cases in a functionality. In most cases, there is no need to create data per test case.
On the other hand, don't share data between two test cases that test different functionalities. It will create dependencies and cause unexpected results. For example, don't share test data between the User module and the Tasks module as changing a user's work timings in a test case in the User module may affect a test case that checks a task's start and finish date assigned to that user in the Task module.
2. Distinguish between read-only and writable test data.
Don't write test cases that overwrite test data required in prerequisites in other test cases. If you do this, the order of test case execution becomes essential. You will never know which test cases to exclude in a test cycle, as excluding them could mean that preconditions of some test cases are not met.
3. Include international and special characters.
Include characters like a single-quote, asterisk, less-than, greater-than, and ampersand that are notorious for causing errors in web applications.
It would help if you also used characters from other languages like Japanese and Thai. They help ensure that those characters are displayed correctly and testing the sort function that is common in many applications.
4. Use import functionality to prevent maintenance problems.
Test data requires maintenance, and sometimes it is time-sensitive. Therefore, it could be wise to generate it using the import functionalities of the application itself—for example, CSV and API. Doing this would mean that the data created in the application is always fresh.
5. Use masked production data before a significant release.
While using tester-created test data has its advantage, always test using anonymized production data. You will always be surprised!