Not able to execute TestNG tests in order wise

classic Classic list List threaded Threaded
5 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.
Reply | Threaded
Open this post in threaded view
|

Re: Not able to execute TestNG tests in order wise

nikhil.shah
Hello,

I am also facing the same issue.


My testng XML:


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="CRM Test">
  <test name="UI Test" group-by-instances="true">
    <classes>
      <class name="test.java.com.testsuite.Class1"/>
      <class name="test.java.com.testsuite.Class2"/>
      <class name="test.java.com.testsuite.Class3"/>
    </classes>
  </test> <!-- UI Test -->
</suite> <!-- CRM Test -->


First Class:


public class Class1{
     @Test(priority = 1, dataProvider = "getData", dataProviderClass = DataUtil.class)
public void Test1(LinkedHashMap<String, String> data) {

     }

     @Test(priority = 2, dataProvider = "getData", dataProviderClass = DataUtil.class)
public void Test2(LinkedHashMap<String, String> data) {

     }

     @Test(priority =3, dataProvider = "getData", dataProviderClass = DataUtil.class)
public void Test3(LinkedHashMap<String, String> data) {

     }

}


Second Class:

public class Class2{
     @Test(priority = 1, dataProvider = "getData", dataProviderClass = DataUtil.class)
public void Test1(LinkedHashMap<String, String> data) {

     }

     @Test(priority = 2, dataProvider = "getData", dataProviderClass = DataUtil.class)
public void Test2(LinkedHashMap<String, String> data) {

     }

     @Test(priority =3, dataProvider = "getData", dataProviderClass = DataUtil.class)
public void Test3(LinkedHashMap<String, String> data) {

     }

}


Third Class:


public class Class3{
     @Test(priority = 1, dataProvider = "getData", dataProviderClass = DataUtil.class)
public void Test1(LinkedHashMap<String, String> data) {

     }

     @Test(priority = 2, dataProvider = "getData", dataProviderClass = DataUtil.class)
public void Test2(LinkedHashMap<String, String> data) {

     }

     @Test(priority =3, dataProvider = "getData", dataProviderClass = DataUtil.class)
public void Test3(LinkedHashMap<String, String> data) {

     }

}


I am generating XML runtime as user says I have to run only Class1 and Class2 then XML contains only Class1 and Class2.

Output:

Class1: Test1
Class2: Test1
Class1: Test2
Class2: Test2
Class1: Test3
Class2: Test3


Expected:

Class1: Test1
Class1: Test2
Class1: Test3

Class2: Test1
Class2: Test2
Class2: Test3


I am using latest testng 6.11





On Monday, November 13, 2017 at 3:27:38 PM UTC+5:30, Pavankumar Vedantham wrote:
We can achieve it by calling the test classes from different test tag in same xml file like below also put prese@rve-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 <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="tIHlublBAQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">adithyar...@...> 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
<a href="https://github.com/test" style="background-color:transparent;color:rgb(36,41,46);font-weight:600;white-space:nowrap" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Ftest\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEzTjhJ7vBuiveWc7vU3EhrEA20ew&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Ftest\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEzTjhJ7vBuiveWc7vU3EhrEA20ew&#39;;return true;">@test(priority=1)
public void test1()
{
}
<a href="https://github.com/test" style="background-color:transparent;color:rgb(36,41,46);font-weight:600;white-space:nowrap" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Ftest\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEzTjhJ7vBuiveWc7vU3EhrEA20ew&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Ftest\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEzTjhJ7vBuiveWc7vU3EhrEA20ew&#39;;return true;">@test(priority=2)
public void test2()
{
}
<a href="https://github.com/test" style="background-color:transparent;color:rgb(36,41,46);font-weight:600;white-space:nowrap" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Ftest\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEzTjhJ7vBuiveWc7vU3EhrEA20ew&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Ftest\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEzTjhJ7vBuiveWc7vU3EhrEA20ew&#39;;return true;">@test(priority=3)
public void test3()
{
}

SecondTestNG.class assume this class also having 3 tests
<a href="https://github.com/test" style="background-color:transparent;color:rgb(36,41,46);font-weight:600;white-space:nowrap" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Ftest\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEzTjhJ7vBuiveWc7vU3EhrEA20ew&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Ftest\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEzTjhJ7vBuiveWc7vU3EhrEA20ew&#39;;return true;">@test(priority=1)
public void secondtest1()
{
}
<a href="https://github.com/test" style="background-color:transparent;color:rgb(36,41,46);font-weight:600;white-space:nowrap" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Ftest\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEzTjhJ7vBuiveWc7vU3EhrEA20ew&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Ftest\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEzTjhJ7vBuiveWc7vU3EhrEA20ew&#39;;return true;">@test(priority=2)
public void secondtest2()
{
}
<a href="https://github.com/test" style="background-color:transparent;color:rgb(36,41,46);font-weight:600;white-space:nowrap" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Ftest\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEzTjhJ7vBuiveWc7vU3EhrEA20ew&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Ftest\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEzTjhJ7vBuiveWc7vU3EhrEA20ew&#39;;return true;">@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 <a href="javascript:" target="_blank" gdf-obfuscated-mailto="tIHlublBAQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">testng-users...@googlegroups.com.
To post to this group, send email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="tIHlublBAQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">testng...@....
Visit this group at <a href="https://groups.google.com/group/testng-users" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/group/testng-users&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/group/testng-users&#39;;return true;">https://groups.google.com/group/testng-users.
For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">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.
Reply | Threaded
Open this post in threaded view
|

Re: Not able to execute TestNG tests in order wise

Julien Herr
Hi,

It is the expected order:
priority is used to order tests in <test> and tests with the same priority will be executed together.

You may use another ordering feature like dependsOnMethods which is class scoped.

Julien

Le mardi 21 novembre 2017 10:47:07 UTC+1, [hidden email] a écrit :
Hello,

I am also facing the same issue.


My testng XML:


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "<a href="http://testng.org/testng-1.0.dtd" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Ftestng.org%2Ftestng-1.0.dtd\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFHihXzQ1YlwcxcDehnw97TuniFLA&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Ftestng.org%2Ftestng-1.0.dtd\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFHihXzQ1YlwcxcDehnw97TuniFLA&#39;;return true;">http://testng.org/testng-1.0.dtd">
<suite name="CRM Test">
  <test name="UI Test" group-by-instances="true">
    <classes>
      <class name="test.java.com.testsuite.Class1"/>
      <class name="test.java.com.testsuite.Class2"/>
      <class name="test.java.com.testsuite.Class3"/>
    </classes>
  </test> <!-- UI Test -->
</suite> <!-- CRM Test -->


First Class:


public class Class1{
     @Test(priority = 1, dataProvider = "getData", dataProviderClass = DataUtil.class)
public void Test1(LinkedHashMap<String, String> data) {

     }

     @Test(priority = 2, dataProvider = "getData", dataProviderClass = DataUtil.class)
public void Test2(LinkedHashMap<String, String> data) {

     }

     @Test(priority =3, dataProvider = "getData", dataProviderClass = DataUtil.class)
public void Test3(LinkedHashMap<String, String> data) {

     }

}


Second Class:

public class Class2{
     @Test(priority = 1, dataProvider = "getData", dataProviderClass = DataUtil.class)
public void Test1(LinkedHashMap<String, String> data) {

     }

     @Test(priority = 2, dataProvider = "getData", dataProviderClass = DataUtil.class)
public void Test2(LinkedHashMap<String, String> data) {

     }

     @Test(priority =3, dataProvider = "getData", dataProviderClass = DataUtil.class)
public void Test3(LinkedHashMap<String, String> data) {

     }

}


Third Class:


public class Class3{
     @Test(priority = 1, dataProvider = "getData", dataProviderClass = DataUtil.class)
public void Test1(LinkedHashMap<String, String> data) {

     }

     @Test(priority = 2, dataProvider = "getData", dataProviderClass = DataUtil.class)
public void Test2(LinkedHashMap<String, String> data) {

     }

     @Test(priority =3, dataProvider = "getData", dataProviderClass = DataUtil.class)
public void Test3(LinkedHashMap<String, String> data) {

     }

}


I am generating XML runtime as user says I have to run only Class1 and Class2 then XML contains only Class1 and Class2.

Output:

Class1: Test1
Class2: Test1
Class1: Test2
Class2: Test2
Class1: Test3
Class2: Test3


Expected:

Class1: Test1
Class1: Test2
Class1: Test3

Class2: Test1
Class2: Test2
Class2: Test3


I am using latest testng 6.11





On Monday, November 13, 2017 at 3:27:38 PM UTC+5:30, Pavankumar Vedantham wrote:
We can achieve it by calling the test classes from different test tag in same xml file like below also put prese@rve-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
<a href="https://github.com/test" style="background-color:transparent;color:rgb(36,41,46);font-weight:600;white-space:nowrap" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Ftest\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEzTjhJ7vBuiveWc7vU3EhrEA20ew&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Ftest\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEzTjhJ7vBuiveWc7vU3EhrEA20ew&#39;;return true;">@test(priority=1)
public void test1()
{
}
<a href="https://github.com/test" style="background-color:transparent;color:rgb(36,41,46);font-weight:600;white-space:nowrap" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Ftest\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEzTjhJ7vBuiveWc7vU3EhrEA20ew&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Ftest\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEzTjhJ7vBuiveWc7vU3EhrEA20ew&#39;;return true;">@test(priority=2)
public void test2()
{
}
<a href="https://github.com/test" style="background-color:transparent;color:rgb(36,41,46);font-weight:600;white-space:nowrap" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Ftest\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEzTjhJ7vBuiveWc7vU3EhrEA20ew&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Ftest\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEzTjhJ7vBuiveWc7vU3EhrEA20ew&#39;;return true;">@test(priority=3)
public void test3()
{
}

SecondTestNG.class assume this class also having 3 tests
<a href="https://github.com/test" style="background-color:transparent;color:rgb(36,41,46);font-weight:600;white-space:nowrap" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Ftest\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEzTjhJ7vBuiveWc7vU3EhrEA20ew&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Ftest\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEzTjhJ7vBuiveWc7vU3EhrEA20ew&#39;;return true;">@test(priority=1)
public void secondtest1()
{
}
<a href="https://github.com/test" style="background-color:transparent;color:rgb(36,41,46);font-weight:600;white-space:nowrap" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Ftest\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEzTjhJ7vBuiveWc7vU3EhrEA20ew&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Ftest\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEzTjhJ7vBuiveWc7vU3EhrEA20ew&#39;;return true;">@test(priority=2)
public void secondtest2()
{
}
<a href="https://github.com/test" style="background-color:transparent;color:rgb(36,41,46);font-weight:600;white-space:nowrap" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Ftest\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEzTjhJ7vBuiveWc7vU3EhrEA20ew&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Ftest\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEzTjhJ7vBuiveWc7vU3EhrEA20ew&#39;;return true;">@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 testng-users...@googlegroups.com.
To post to this group, send email to [hidden email].
Visit this group at <a href="https://groups.google.com/group/testng-users" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://groups.google.com/group/testng-users&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/group/testng-users&#39;;return true;">https://groups.google.com/group/testng-users.
For more options, visit <a href="https://groups.google.com/d/optout" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">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.
Reply | Threaded
Open this post in threaded view
|

Re: Not able to execute TestNG tests in order wise

nikhil.shah
Thanks Julien Herr.

On Tuesday, November 21, 2017 at 9:23:01 PM UTC+5:30, Julien Herr wrote:
Hi,

It is the expected order:
priority is used to order tests in <test> and tests with the same priority will be executed together.

You may use another ordering feature like dependsOnMethods which is class scoped.

Julien

Le mardi 21 novembre 2017 10:47:07 UTC+1, <a href="javascript:" target="_blank" gdf-obfuscated-mailto="oezlEbrcBwAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">nikhi...@... a écrit :
Hello,

I am also facing the same issue.


My testng XML:


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "<a href="http://testng.org/testng-1.0.dtd" rel="nofollow" target="_blank" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Ftestng.org%2Ftestng-1.0.dtd\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFHihXzQ1YlwcxcDehnw97TuniFLA&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Ftestng.org%2Ftestng-1.0.dtd\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFHihXzQ1YlwcxcDehnw97TuniFLA&#39;;return true;">http://testng.org/testng-1.0.dtd">
<suite name="CRM Test">
  <test name="UI Test" group-by-instances="true">
    <classes>
      <class name="test.java.com.testsuite.Class1"/>
      <class name="test.java.com.testsuite.Class2"/>
      <class name="test.java.com.testsuite.Class3"/>
    </classes>
  </test> <!-- UI Test -->
</suite> <!-- CRM Test -->


First Class:


public class Class1{
     @Test(priority = 1, dataProvider = "getData", dataProviderClass = DataUtil.class)
public void Test1(LinkedHashMap<String, String> data) {

     }

     @Test(priority = 2, dataProvider = "getData", dataProviderClass = DataUtil.class)
public void Test2(LinkedHashMap<String, String> data) {

     }

     @Test(priority =3, dataProvider = "getData", dataProviderClass = DataUtil.class)
public void Test3(LinkedHashMap<String, String> data) {

     }

}


Second Class:

public class Class2{
     @Test(priority = 1, dataProvider = "getData", dataProviderClass = DataUtil.class)
public void Test1(LinkedHashMap<String, String> data) {

     }

     @Test(priority = 2, dataProvider = "getData", dataProviderClass = DataUtil.class)
public void Test2(LinkedHashMap<String, String> data) {

     }

     @Test(priority =3, dataProvider = "getData", dataProviderClass = DataUtil.class)
public void Test3(LinkedHashMap<String, String> data) {

     }

}


Third Class:


public class Class3{
     @Test(priority = 1, dataProvider = "getData", dataProviderClass = DataUtil.class)
public void Test1(LinkedHashMap<String, String> data) {

     }

     @Test(priority = 2, dataProvider = "getData", dataProviderClass = DataUtil.class)
public void Test2(LinkedHashMap<String, String> data) {

     }

     @Test(priority =3, dataProvider = "getData", dataProviderClass = DataUtil.class)
public void Test3(LinkedHashMap<String, String> data) {

     }

}


I am generating XML runtime as user says I have to run only Class1 and Class2 then XML contains only Class1 and Class2.

Output:

Class1: Test1
Class2: Test1
Class1: Test2
Class2: Test2
Class1: Test3
Class2: Test3


Expected:

Class1: Test1
Class1: Test2
Class1: Test3

Class2: Test1
Class2: Test2
Class2: Test3


I am using latest testng 6.11





On Monday, November 13, 2017 at 3:27:38 PM UTC+5:30, Pavankumar Vedantham wrote:
We can achieve it by calling the test classes from different test tag in same xml file like below also put prese@rve-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
<a href="https://github.com/test" style="background-color:transparent;color:rgb(36,41,46);font-weight:600;white-space:nowrap" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Ftest\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEzTjhJ7vBuiveWc7vU3EhrEA20ew&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Ftest\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEzTjhJ7vBuiveWc7vU3EhrEA20ew&#39;;return true;">@test(priority=1)
public void test1()
{
}
<a href="https://github.com/test" style="background-color:transparent;color:rgb(36,41,46);font-weight:600;white-space:nowrap" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Ftest\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEzTjhJ7vBuiveWc7vU3EhrEA20ew&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Ftest\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEzTjhJ7vBuiveWc7vU3EhrEA20ew&#39;;return true;">@test(priority=2)
public void test2()
{
}
<a href="https://github.com/test" style="background-color:transparent;color:rgb(36,41,46);font-weight:600;white-space:nowrap" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Ftest\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEzTjhJ7vBuiveWc7vU3EhrEA20ew&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Ftest\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEzTjhJ7vBuiveWc7vU3EhrEA20ew&#39;;return true;">@test(priority=3)
public void test3()
{
}

SecondTestNG.class assume this class also having 3 tests
<a href="https://github.com/test" style="background-color:transparent;color:rgb(36,41,46);font-weight:600;white-space:nowrap" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Ftest\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEzTjhJ7vBuiveWc7vU3EhrEA20ew&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Ftest\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEzTjhJ7vBuiveWc7vU3EhrEA20ew&#39;;return true;">@test(priority=1)
public void secondtest1()
{
}
<a href="https://github.com/test" style="background-color:transparent;color:rgb(36,41,46);font-weight:600;white-space:nowrap" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Ftest\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEzTjhJ7vBuiveWc7vU3EhrEA20ew&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Ftest\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEzTjhJ7vBuiveWc7vU3EhrEA20ew&#39;;return true;">@test(priority=2)
public void secondtest2()
{
}
<a href="https://github.com/test" style="background-color:transparent;color:rgb(36,41,46);font-weight:600;white-space:nowrap" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Ftest\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEzTjhJ7vBuiveWc7vU3EhrEA20ew&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Ftest\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEzTjhJ7vBuiveWc7vU3EhrEA20ew&#39;;return true;">@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 testng-users...@googlegroups.com.
To post to this group, send email to [hidden email].
Visit this group at <a href="https://groups.google.com/group/testng-users" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://groups.google.com/group/testng-users&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/group/testng-users&#39;;return true;">https://groups.google.com/group/testng-users.
For more options, visit <a href="https://groups.google.com/d/optout" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">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.