Wednesday, April 2, 2014

Data Driven Testing in TestNG using Factory Pattern

In the previous post we have looked at how to write test cases for data driven testing using data provider. Now let us look how to do same using Factory pattern.

Reading excel sheet will be same as previous

Now let us use Factory annotation and passing one set of data at a time to TestNG for running the same Test case multiple times (Data driven Testing). The main difference between Factory pattern and dataProvider is that in dataProvider all the tests will be called on a single instance and in factory pattern each test case will be called on different instances.

Here every test data will have a corresponding object of the class ProjectTestCases.


No comments:

Post a Comment