Inizia ora la tua demo e risparmia sui primi 12 mesi!

Blog

A Data-Driven Example

Pubblicato da Il 14 Luglio 2020 in Blog, Tips

Data-Driven Testing allows writing test cases as scripts that read their data from external sources. By this approach, one script can drive many tests just by changing the tests’ data.

Using this feature is quite simple. Here are Java and Keywords examples to test a very easy login form retrieving test data from an MS Excel file according to the following scheme.



To manage the data source, in this case, it’s possible creating a data manager using the constructor provided by the TestDataManager class and the path of the MS Excel data file.



To retrieve the test data from the storage, in this example there is the function String getData(String metadata).



As an alternative to the Java coding approach, it is possible to write this test case as another MS Excel file by using some Keywords and the syntax ${file path}{test data}{data id} or #{i} to iterate, like in the following example.



Obviously, this example can not cover all the things to say about the data-driven approach. If you are interested don’t be shy and feel free to ask and contribute.