I have my integration test suite running on TestNG and utilizing its annotations. In simplified case I have 3 test classes that contain 1 configuration test and some dependable on the configuration tests.
TestClass1
@Test()
configureTestMethod() {}
@Test(dependsOnMethods=["configureTestMethod"])
testCase1_1() {}
@Test(dependsOnMethods=["configureTestMethod"])
testCase1_2() {}
TestClass2
@Test()
configureTestMethod() {}
@Test(dependsOnMethods=["configureTestMethod"])
testCase2_1() {}
@Test(dependsOnMethods=["configureTestMethod"])
testCase2_2() {}
TestClass3
@Test()
configureTestMethod() {}
@Test(dependsOnMethods=["configureTestMethod"])
testCase3_1() {}
@Test(dependsOnMethods=["configureTestMethod"])
testCase3_2() {}
My problem that when I run all those 3 test classes it runs it in the following order: TestClass1.configureTestMethod(), TestClass2.configureTestMethod(), TestClass3.configureTestMethod(), TestClass1.testCase1_1(), TestClass1.testCase1_2(), TestClass2.testCase2_1(), TestClass2.testCase2_2(), ...etc...
I know it makes sense cause there are no dependencies between configureTestMethod() in different classes so for TestNG their order doesn't meter.
How can I run all test methods of test classes before proceeding to another test class?
The directions I discovered so far:
Define dependencies between configureTestMethod() in different test classes. It means I can't run a single test class cause it's dependent on another one.
Implementing method interceptor. I'm getting there three configureTestMethod() methods and it doesn't matter for me in which order it's executed. I want to run their class methods first, so I'm sure how I can control it in the interceptor.
@BeforeClass
? – Amir Pashazadeh