Question

I have the following situation: I create a class with a single test method, within this test method, I create another class that contains multiple test methods.

The report shows only my initial test method, it passes IFF it passes and all the tests in the other class pass.

What I wish would happen is the report would contain my first test, and also the results of all the other tests in the other class passing, or failing.

Do you know of a way to do this?

Was it helpful?

Solution

this is not possible. testNG wraps your test classes and instruments them, so making a 'new' test class in your test does not create all the extra testNG stuff with it, which is why when test methods run within it, looks like they ran inside the original test methods from which the class was instantiated.

long story short: you cant do it, unless you did some stuff with testNG under the hood. It would be easier to just proxy the test methods inside of your test class

OTHER TIPS

go to configure the testng option and select suite option and pick the xml file that contains all the methods.

There is similar question test structure using testNG where are some answers that maybe interesting for you.

It is possible using @Factory implementation. Take a look at this answer:What's the difference between DataProvider and Factory in TestNG?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top