2

I am working on a Java/TestNG UI automation framework and having some difficulties with test data management.

I use TestNG's DataProvider to pass data to the test method. I need to pass about 30 variables to test an end to end scenario and I have about 150 scenarios to test.

I saved each variable in a cell in an excel sheet and treat each row as a scenario. (150 rows, 30 cells in each row)

So I read the items in one row, create my Java object using those variables and pass that object to my test method to test one scenario.

Managing this data is a little difficult. Is there a preferred approach for this kind of problem?

  • What exactly is difficult? I want to know to answer your question, because simply adding values to an Excel doesn't seem that overwhelming. – FDM May 26 '17 at 12:40
1

One TestNG approach is to use Parameterized Tests

See https://www.tutorialspoint.com/testng/testng_parameterized_test.htm

Another interesting feature available in TestNG is parametric testing. In most cases, you'll come across a scenario where the business logic requires a hugely varying number of tests. Parameterized tests allow developers to run the same test over and over again using different values.

1

When the growth of your data leads to a situation where managing the data is becoming burdensome, one option that I would consider would be moving to a formal database for storage of that information.
You could have various tables to store the data.
You will need a UI to manage the data of course. With mySQL that could simply be SQLworkbench (free). Another option is to create a simple UI for that data, e.g. build a simple app using Ruby-on-Rails or Sinatra.

0

If you find that most data tends to be key-value pairs, e.g. for this element use this value, for that element use that value, etc. you may want to store the data as key-value pairs in a file. You can then access that file and if desired read the key-value pairs into dynamically created methods for a data provider object. You can also use systems such as redis that are based on key-value pairs as this may address sharing the data without physically passing around a file (or access to it).

0

Just like the PageObject pattern where you store locators and actions in a class I like to use a class as a central test-data store.

Just like data-structure classes you can create test-data classes. It should have some public variables or methods that return single data entries or arrays/lists you can use in parameterized tests.

I would alway try to prevent to use Excel. As it is hard(er) to version with the code, because it is a binary file format. Also developers need to use an extra tool to update the tests for their code. Going back and forth between the test-data and the code, horrible, better if you can stay in your IDE.

Put the test-data next to your code, unless you have non technical people who need to update the test-data. In that case I would use something like Fitnesse where you map (unit-)tests with data in a Wiki.

Ask yourself these questions:

  • Can I version my data?
  • Do I need extra tools?
  • Do I have on technical people who need to update test-data?

Try to keep it as simple as possible. Excel just adds complexity you do not need probably. Apply the YAGNI principle.

-1

Excel is one of the ways to store your input data.

  1. You can also use .properties file as in a key-value pair for the same purpose.
  2. Or you create a BaseClass (or TestData Class) which you can extend(inherit) into your Test class.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.