Not able to execute TestNG tests in order wise

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Not able to execute TestNG tests in order wise

adithya vardhanreddy

I want to execute my TestNG Class tests in order wise how they have written from to to bottom. To achive this right now i am using priority for each test in one testNG class.

Sample TestNg Class:
FirsttestNG.class assume this class is having 3 tests as shown below
@test(priority=1)
public void test1()
{
}
@test(priority=2)
public void test2()
{
}
@test(priority=3)
public void test3()
{
}

SecondTestNG.class assume this class also having 3 tests
@test(priority=1)
public void secondtest1()
{
}
@test(priority=2)
public void secondtest2()
{
}
@test(priority=3)
public void secondtest3()
{
}

When i execute above mentioned classes alone from testNg xml file the out put will be as shown below.
for FirstTestNgClass out put : first test1 method will execute then test2 follwed by test3.
for SecondtestNg class also execution sequence will be same.

Now the problem is when i execute both FirstTestNG and SecondTestNG Classes at a time form testNg xml then execution sequence will be
Out Put
test1
secondtest1
test2
secondtest2
test3
secondtest3

but i want as shown below:
out Put:
test1
test2
test3
secondtest1
secondtest2
secondtest3

can we achive this ?

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Not able to execute TestNG tests in order wise

Pavankumar Vedantham
We can achieve it by calling the test classes from different test tag in same xml file like below also put preserve-order =true at suite level:

<test name="Test 1">

  <classes>

  <class name="FirstTestNG"></class>

   </classes>

 </test>

  <test name="Test 2">

  <classes>

   <class name="SecondTestNG"></class>

   </classes>

  </test>


On Mon, Nov 13, 2017 at 12:34 PM, adithya vardhanreddy <[hidden email]> wrote:

I want to execute my TestNG Class tests in order wise how they have written from to to bottom. To achive this right now i am using priority for each test in one testNG class.

Sample TestNg Class:
FirsttestNG.class assume this class is having 3 tests as shown below
@test(priority=1)
public void test1()
{
}
@test(priority=2)
public void test2()
{
}
@test(priority=3)
public void test3()
{
}

SecondTestNG.class assume this class also having 3 tests
@test(priority=1)
public void secondtest1()
{
}
@test(priority=2)
public void secondtest2()
{
}
@test(priority=3)
public void secondtest3()
{
}

When i execute above mentioned classes alone from testNg xml file the out put will be as shown below.
for FirstTestNgClass out put : first test1 method will execute then test2 follwed by test3.
for SecondtestNg class also execution sequence will be same.

Now the problem is when i execute both FirstTestNG and SecondTestNG Classes at a time form testNg xml then execution sequence will be
Out Put
test1
secondtest1
test2
secondtest2
test3
secondtest3

but i want as shown below:
out Put:
test1
test2
test3
secondtest1
secondtest2
secondtest3

can we achive this ?

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.