Data-driven testing (DDT), which can also be called table-driven testing or parameterized testing, is one of the common testing methodology in software development world.
Datat-driven testing (DTT) is mostly used to test many computer software and it is use to describe some type of testing done using a table of conditions directly as test inputs and known outputs as well as the process where test environment.
If you have found yourself struggling with data-driven testing using Apache POI jars, you are not alone.
We all know that you cannot be casual and fun around POI in your framework. You would have discovered after writing a lot of lines of code that you are somewhat lost. And just think about someone who is trying to review your framework and get themselves solving the jumbled wiring of the data-driven testing part.
It was not long ago that I came across a product from Codoid; named - Fillo. I was very apprehensive at the start but when I saw the documentation it made sense.
A simple library that gives you an interesting outlook towards firing up your data-driven testing game. You do not have to do anything with your test data, that remains in the excel sheet.
However, Fillo changes the way you read and manipulate your test data in the sheet. It gives you the capability to write SQL query like instructions to read, write data into excel. SQL? You ask. Unbelievable, right?
How? That was my question too and I did not waste any time in using it first hand. I can only tell you; Great, Great Stuff!
So, let us see some interesting stuff from Fillo and share our awe and amazement all across if you have not experienced it yet.
It is good to go through simple documentation on Fillo @ https://codoid.com/fillo/
Create a Maven project in your IDE. Download the Maven dependency and add to your project's pom.xml file.
<!-- https://mvnrepository.com/artifact/com.codoid.products/fillo --> <dependency> <groupId>com.codoid.products</groupId> <artifactId>fillo</artifactId> <version>1.21</version> </dependency>
Let us create two packages in /src/main/java, namely: /data manager and /filloReader, where former will be used to keep the excel file with test data and /filloReader will be used to keep get and update data utilities.
We also would need to create a test class in /src/test/java. We will be avoiding any boilerplate code and would only focus on getting and updating the data in the excel sheet using the Fillo library.
The project structure looks like this:
Test1 excel file data looks like this:
Now let us start coding FilloUtility class, where we will add one method: to fetch the data from the excel file.
Mainly we need to use the below SQL query:
"Select * from Sheet1 where TestNumber=1"
That looks so easy. Right?
Here is the code snippet for the get method utility:
So we can see that we have got some classes from Fillo library like Connection, Fillo and Recordset.
We have to pass the filepath of the excel data in the Connection object.
The recordset is used to store the value fetched by the Select query.
You can also get this code from BusyQA GitHub public repository https://github.com/busyqaautomation/FilloDataDrivenTest