mkoryak
mkoryak

Reputation: 57938

running multiple TestNG testcases from a single testcase

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?

Upvotes: 1

Views: 2788

Answers (3)

Noam Manos
Noam Manos

Reputation: 16971

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

Upvotes: 0

sameera
sameera

Reputation: 11

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

Upvotes: 1

mkoryak
mkoryak

Reputation: 57938

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

Upvotes: 1

Related Questions