1
votes

I have 2 classes.

Class 1:

@Test
public void test1(){
    System.out.println("test1-1");
}

@Test(priority = 1)
public void test2(){
    System.out.println("test2-1");
}

@Test(priority = 6)
public void test3(){
    System.out.println("test3-1");
}

@Test(priority = 9)
public void test4(){
    System.out.println("test4-1");
}


Class 2:

@Test
public void test1(){
    System.out.println("test1-2");
}

@Test(priority = 1)
public void test2(){
    System.out.println("test2-2");
}

@Test(priority = 2)
public void test3(){
    System.out.println("test3-2");
}

@Test(priority = 3)
public void test4(){
    System.out.println("test4-2");
}


XML:

<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >

<suite name="Smoke" verbose="1" parallel="tests" thread-count="5" >
    <test name="GalaxyS7">
        <classes>
            <class name="TempTest.ClassTest1"/>
            <class name="TempTest.ClassTest2"/>
        </classes>
    </test>
</suite>

And when I execute test expected output is:

test1-1
test2-1
test3-1
test4-1
test1-2
test2-2
test3-2
test4-2

But actual output is:

test1-1
test1-2
test2-1
test2-2
test3-2
test4-2
test3-1
test4-1

But when I removing parallel="tests", execution as expected. When I removing priorities but parallel="tests" stays in XML - execution as expected. But I'm trying to run my tests in parallel and have priorities there as well.

Is it a bug in TestNG or I'm missing something?

Any help is appreciated. My goal is to run all test cases from the first class and then from the 2nd class.

1

1 Answers

0
votes

As best as I can tell you seem to be expecting that each instance of an object has it's own set of priorities when running in parallel mode, while your test suite treats priorities as global variables, also when priorities are equal it handles then in a top down matter (TempTest.ClassTest1 then TempTest.ClassTest2).

tl;dr:
priority is used on a global scale, not on an instance one.