|In my last couple of posts, Structure of Automation Test Cases and |
Best Test Structure::Hermetic Test Pattern , I have shown each testcase
should be independent to each other. But to make them real
independent it requires testdata manipulation. Testdata also need to
be independent ad unique in nature.
Why it is required?
It is required to stop data pollution.Stop using polluted data usage
inflow and outflow.
I am writing few common methods to make testdata independent:
- Use testcase id or name at the end of the testdata like Cutomer_Name=”Rabin”+”Test123”;
- Use time stamp to make testdata unique like-Customer_Name=”Rabin”+”3103201515082015”;
- Use random number generator to create unique testdata.like-“Robin”+rand.nextInt(900) + 100;
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 digit random number.
AtomicInteger counter = new AtomicInteger(1); counter.getAndIncrement();This is also very useful to get unique number.