1

I am using Gradle 4.6 with testng. My test suite has tests organized something like these.

java class1 { test 1.1 test 1.2 test 1.3 test 1.4 }

java class2 java class3 java class4 java class5

All these classes have total 100 tests in the suite. When I execute the suite, gradle first executes, tests 1.1 and 1.2 and then goes and executes all the tests in class2 to 5 and finally comes back to class 1 to execute 1.3 and 1.4.

Is there a way we can force all the tests in a class to be executed before going to class? For example, it will be helpful, I get all my tests in class1 completes execution, then goes to next class (in any order) and so on.

I do not want to set dependency as any failures will force the dependent test to skip, these are independent tests, eventhough there is some dependency declared tests within the same class.

0

As far as I know, Gradle does not control the execution order. Instead use the TestNG priority annotation.

example:

@Test(priority=0)
public void test1(){

System.out.println("First Test");
}


@Test(priority=1)
public void test2(){

System.out.println("Second Test");
}

And maybe set the order for classes in Testng.xml e.g here.

  • This I can try, but for example I said 100, but there are around 600+ tests spread across like 30+ classes in my case. keeping track of priority tag for each test is difficult, can we have something at class level? – Venkat Oct 7 at 13:03
  • I added an example to my answer. Maybe it helps. – masood ghz Oct 7 at 14:53
  • Thanks.. will try this – Venkat Oct 10 at 5:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.