0
votes

I am working with testNG where I run an external test framework, receive the result data and assert it. To run the external test framework I need to set up a specification for which tests that should be run. To generate this specification I need to know which tests that are selected in the testNG .xml file.

The only way I could think of doing this is to parse the file manually. But I am hoping for a better solution than this.

Thanks for any answers! //Flipbed

Edit:

My colleague found solutions to the problem.

  1. In @Factory and @DataProvider annotated methods it is possible to add a parameter of the type ITestContext. Using the variable of that type, one can use the method .getAllTestMethods().
  2. Create a new class that implements IMethodInterceptor. In this class one can override the method 'intercept'. The method takes a parameter of the type List which is a list of all methods that will be run by testNG.

If someone has any other suggestions feel free to add.

//Flipbed

1

1 Answers

0
votes

The solution that we used was to number 2 in my edit. We implemented the IMethodInterceptor and used the methods list as well as the ITestContext to both view what tests will run and modify that list.