0

I am experiencing the following problem. I have set up a grid with 2 nodes, in order to run tests in parallel.My suite.xml file has two groups, one for each node:

<suite name="testSuites"  configfailurepolicy="continue"   thread-count="2" parallel="tests">
 test name="testSuite1" preserve-order="true">
 <classes>
    <class name="testA1" />
    <class name="testB1" />
    <class name="testC1" /> 
</classes>
 </test>
 <test name="testSuite2" preserve-order="true">
 <classes>
    <class name="testA2" />
    <class name="testB2" />
    <class name="testC2" /> 
</classes>
 </test>

Each class, for example testA1 has the following testNG configuration:

 @BeforeClass(alwaysRun = true)
    public void createInitialData()  {  
}

    @Test(alwaysRun = true, description = "bla bla")
    public void testStep_1() throws Exception{

    }

    @Test(alwaysRun = true, description = "bla bla ", dependsOnMethods ="testStep_1" )
    public void testStep_2() {
    }

Upon running I noticed that during the execution, the tests are executing in test step wise order, meaning:

testA1-testStep_1, testB1-testStep_1, testC1-testStep_1, testA1-testStep_2, testB1-testStep_2, testC1-testStep_2

whereas it should have been:

testA1-testStep_1, testA1-testStep_2, and then testB1-testStep_1, testB1-testStep_2, testC1-testStep_1, testC1-testStep_2

Any suggestions?

Kuba Spatny
  • 26,618
  • 9
  • 40
  • 63
stelios.p
  • 177
  • 4
  • 10
  • Did you try to give priority to tests? – Helping Hands Apr 14 '15 at 08:53
  • No. But why I should?According to testNG documentation:_priority: The priority for this test method. Lower priorities will be scheduled first._ So this means that test methods with same priority, probably will experience the same problem.Also I don't want to fill hundreds of test classes with priority annotations – stelios.p Apr 14 '15 at 09:01

2 Answers2

1

Try to set group-by-instances in your xml

<suite  group-by-instances="true">

or

<test group-by-instances="true">
peetya
  • 3,578
  • 2
  • 16
  • 30
  • Hey peetya, I tried `` and it seems to be working. I'll run some more tests, and come to a final conclusion. – stelios.p Apr 15 '15 at 07:37
  • By the way, I would like to ask both peetya and @user1058106, where did they found the proposed annotations as an application to parallel testing, and if there is a tutorial documenting such practices – stelios.p Apr 15 '15 at 07:41
  • I had a similar question before: http://stackoverflow.com/questions/26632241/priority-in-testng-with-multiple-classes And you can find here a little example in the documentation: http://testng.org/doc/documentation-main.html#dependencies-with-annotations – peetya Apr 15 '15 at 09:44
  • Ηey peetya. That's the problem, that there is little example in the official documentation. Moreover, it is not always obvious which parameter solves your problem, and which not. Any progress on passing the parameter programmatically? – stelios.p Apr 15 '15 at 12:28
  • Yes we found out that there is a bug in testng source code and it has been fixed already. Here you can find the commit: https://github.com/cbeust/testng/commit/cf3f9f7f67e95df3e7668a67ffaf00ffdaae1e4b – peetya Apr 15 '15 at 12:41
0
<test name="testSuite2" parallel="false">

Seem also be doing what you need.

user1058106
  • 530
  • 3
  • 12