mercredi 14 décembre 2016

How to change the @Test method dynamically in TestNG

This is more of a question on test automation framework design. I am creating a test automation framework using Selenium. Mostly I am accessing the data (methods name) from an excel file.

In my main Runner class I am getting a list of test cases. Each test case has a set of methods (can be same or different) which I have defined in a java class and executing each method using java reflection api. Everything is fine till this point.

Now I want to incorporate TestNG and reporting/logging in my automation suite. Problem is I cant use @Test for each method as TestNG considers @Test = 1 Test Case - but my 1 Test case might have more than 1 methods. My methods are more like a test steps for a test case, reason is I dont want repeat the code. I want to create a @Test dynamically calling different sets of methods and executing them in Java. Changing the content of @Test method. I was going through the TestNG documentation, but could not able to locate any feature to handle this situation.

Any help is really appreciated and if you have any other thoughts to handle this situaton I am here to listen.

Aucun commentaire:

Enregistrer un commentaire