In my last couple of posts, Structure of Automation Test Cases and
Best Test Structure:: Hermetic Test Pattern, I have shown each test case should be independent to each other. But to make them really independent it requires test data manipulation. Test data also need to be independent and unique in nature.
Why test data creation is required?
It is required to stop data pollution.Stop using polluted data usage inflow and outflow.
I am writing a few common methods to make test data independent:
Ways:
- Use test cases id or name at the end of the test data like Cutomer_Name=”Rabin”+”Test123″;
- Use timestamp to make test data unique like-Customer_Name=”Rabin”+”3103201515082015”;
- Use random number generator to create unique testdata.like-“Robin”+rand.nextInt(900) + 100;
I like the Random number generation method and if it is not possible to use, I generally use the test case id.
More note on Random number generation:
RandomStringUtils.random(10, false,true);
you need to import – org.apache.commons.lang3.RandomStringUtils package
this is very useful when generating 10 digits random number.
AtomicInteger counter = new AtomicInteger(1); counter.getAndIncrement();
This is also very useful to get a unique number.
Knowledge is the key for test data creation
Training of the product is an important aspect in order to create test data for a large test set. Joining the story grooming session may be very important. A larger development group with an equally large test team with a lack of knowledge on the product may fail in the long run when development is in agile or rapid development mode.
This lack of knowledge will produce less important test data or some test data which are are not up to the mark for bug catching purpose. Overall the product and testing will have poor quality.
Next, the development team will tend to ignore the issues raised by the test team due to lack of knowledge and insufficient test data.
Use of test data testing tool
A database testing tool for APIs queries to the database can be written in Java, JDK, JDBC, and SQL. This may support testing for some small scale testing. But when your team is quite big, and you are dealing with large test data, You better use some test data generation and automation tool for tailor make the test data for your automation.
TestData life cycle
Every testdata upon creation should get a review from the scrum team for its effectiveness. There could be reworked for the same. The reviewed test data is called a candidate for testing. Automation team may make it active and put in the test suite or they may suspend the test data. All suspended test data needs further review or rework to make it effective. Once the review process is completed, it is valid to test for the flow. Now the active test data once serve significance amount of time, automation team may scrap the same and declare it as retired. All retired test data are marked for deletion for an effective new data.