The TestNG Data Provider class

TestNG has a Data Provider feature that allows users to extract test data in any format. It returns an array of objects, which can be cast to a POJO (Plain Old Java Object; that is, no set of rules to follow) such as a JSONObject type. When creating the class with the method for extracting the data, users tag the method using the @DataProvider annotation.

The DataProvider method could be stored in the same class as the Test, but it makes more sense to create a generic static method in a separate class so all test classes can use the same DataProvider and format. Having a consistent format to encapsulate data will make it easier for users to maintain and enhance the framework and tests.

Finally, when storing the method in a separate class, the DataProvider method name and class must be passed to the @Test annotation as an attribute. We will explore a few examples in this section.

The TestNG DataProvider JavaDoc is located at http://testng.org/doc/documentation-main.html#parameters-dataproviders.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.116.50.87