Unable to execute testng tests in a particular order

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

Unable to execute testng tests in a particular order

Kiran
Hi,

I have a testng class which has 6 test methods in it. I would like to execute the methods in a particular order since each test depends on its previous test. I see the first two tests are executing in sequence[i.e abNavigateTest and addAdvGroup - please see below testng.xml] but testng ignores the 3rd test(addAdvt) and picks the 4th test instead. I assume Testng executes tests in alphabetical order and maintains the order specified in testng.xml. 

I have tried setting preserve-order=true and setting priority for each test but it appears to be not working for my case. Sorry, I am sure but it might have worked for others! I also would like to avoid using dependsOnMethods.

Could some one please have look on this ? I am not sure what else I need to add to make testng to run the tests in the order specified in testng.xml ? Please find below the testng.xml, test details and let me know if you need more details. Thank you!



testng.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="MDM Smoke Tests" >
<listeners>
<listener class-name="org.uncommons.reportng.HTMLReporter" />
<listener class-name="org.uncommons.reportng.JUnitXMLReporter" />
</listeners>
<test verbose="2" name="MDM Smoke Tests">
<classes>
<!-- <class name="com.mdm.functional.test.AgencyTest"/> -->
<class name="com.mdm.functional.test.MDMOrgTest" >
<methods>
<include name="abNavigateTest" />
<include name="addAdvGroup" />
<include name="addAdvt" />
<include name="addBrand" />
<include name="addProduct" />
<include name="Budget" />
<include name="BudgetLine" />
</methods>
</class>
<!-- <class name="com.mdm.functional.test.PublisherTest"/> -->
</classes>
</test>
</suite>


Test file will looks like this

package com.mdm.functional.test;


import java.net.URL;
import java.util.HashMap;

import org.apache.log4j.Logger;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;



public class MDMOrgTest extends MdmTestBase {

@BeforeTest
public void init(){
}
@Test()
public void abNavigateTest()
{
}
@Test(dataProvider = "OrganisationData")
public void addAdvGroup(HashMap<String, String> orgData)
{
}
@Test(dataProvider = "OrganisationData")
public void addAdvt(HashMap<String, String> orgData)
{
}
@Test(dataProvider = "OrganisationData")
public void addBrand(HashMap<String, String> orgData)
{
}
@Test(dataProvider = "OrganisationData")
public void addProduct(HashMap<String, String> orgData)
{
}
@Test(dataProvider="budgetData")
public void Budget(HashMap<String, String> orgData)
{
}
@Test(dataProvider="budgetLineData")
public void BudgetLine(HashMap<String, String> orgData)
{
}
@DataProvider(name = "OrganisationData")
    public Object[][] organisationData() throws Exception 
    {
    }
@DataProvider(name="budgetData")
public Object[][] budgetData() throws Exception
{
}
@DataProvider(name="budgetLineData")
public Object[][] bugetLineData() throws Exception
{
}
private  Object[][] readyOgData(String sheetName){
}
private  Object[][] readBudgetData(String sheetName){
}
private  Object[][] readBudgetLineData(String sheetName){
}
}




--
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 http://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/groups/opt_out.
Reply | Threaded
Open this post in threaded view
|

Re: Unable to execute testng tests in a particular order

praveen133t
try specifying @Priority(n), ... for each test based on how you need them to run.


On Friday, January 17, 2014 2:59:04 PM UTC-6, Kiran wrote:
Hi,

I have a testng class which has 6 test methods in it. I would like to execute the methods in a particular order since each test depends on its previous test. I see the first two tests are executing in sequence[i.e abNavigateTest and addAdvGroup - please see below testng.xml] but testng ignores the 3rd test(addAdvt) and picks the 4th test instead. I assume Testng executes tests in alphabetical order and maintains the order specified in testng.xml. 

I have tried setting preserve-order=true and setting priority for each test but it appears to be not working for my case. Sorry, I am sure but it might have worked for others! I also would like to avoid using dependsOnMethods.

Could some one please have look on this ? I am not sure what else I need to add to make testng to run the tests in the order specified in testng.xml ? Please find below the testng.xml, test details and let me know if you need more details. Thank you!



testng.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "<a href="http://testng.org/testng-1.0.dtd" target="_blank" onmousedown="this.href='http://www.google.com/url?q\75http%3A%2F%2Ftestng.org%2Ftestng-1.0.dtd\46sa\75D\46sntz\0751\46usg\75AFQjCNFHihXzQ1YlwcxcDehnw97TuniFLA';return true;" onclick="this.href='http://www.google.com/url?q\75http%3A%2F%2Ftestng.org%2Ftestng-1.0.dtd\46sa\75D\46sntz\0751\46usg\75AFQjCNFHihXzQ1YlwcxcDehnw97TuniFLA';return true;">http://testng.org/testng-1.0.dtd">
<suite name="MDM Smoke Tests" >
<listeners>
<listener class-name="org.uncommons.reportng.HTMLReporter" />
<listener class-name="org.uncommons.reportng.JUnitXMLReporter" />
</listeners>
<test verbose="2" name="MDM Smoke Tests">
<classes>
<!-- <class name="com.mdm.functional.test.AgencyTest"/> -->
<class name="com.mdm.functional.test.MDMOrgTest" >
<methods>
<include name="abNavigateTest" />
<include name="addAdvGroup" />
<include name="addAdvt" />
<include name="addBrand" />
<include name="addProduct" />
<include name="Budget" />
<include name="BudgetLine" />
</methods>
</class>
<!-- <class name="com.mdm.functional.test.PublisherTest"/> -->
</classes>
</test>
</suite>


Test file will looks like this

package com.mdm.functional.test;


import java.net.URL;
import java.util.HashMap;

import org.apache.log4j.Logger;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;



public class MDMOrgTest extends MdmTestBase {

@BeforeTest
public void init(){
}
@Test()
public void abNavigateTest()
{
}
@Test(dataProvider = "OrganisationData")
public void addAdvGroup(HashMap<String, String> orgData)
{
}
@Test(dataProvider = "OrganisationData")
public void addAdvt(HashMap<String, String> orgData)
{
}
@Test(dataProvider = "OrganisationData")
public void addBrand(HashMap<String, String> orgData)
{
}
@Test(dataProvider = "OrganisationData")
public void addProduct(HashMap<String, String> orgData)
{
}
@Test(dataProvider="budgetData")
public void Budget(HashMap<String, String> orgData)
{
}
@Test(dataProvider="budgetLineData")
public void BudgetLine(HashMap<String, String> orgData)
{
}
@DataProvider(name = "OrganisationData")
    public Object[][] organisationData() throws Exception 
    {
    }
@DataProvider(name="budgetData")
public Object[][] budgetData() throws Exception
{
}
@DataProvider(name="budgetLineData")
public Object[][] bugetLineData() throws Exception
{
}
private  Object[][] readyOgData(String sheetName){
}
private  Object[][] readBudgetData(String sheetName){
}
private  Object[][] readBudgetLineData(String sheetName){
}
}




--
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 http://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/groups/opt_out.
Reply | Threaded
Open this post in threaded view
|

Re: Unable to execute testng tests in a particular order

Kiran
thanks Talon! It just happened that I decided to separate all the tests in testsng.xml since it is cumbersome to have tests which are dependent on each other. All the tests runs in the order I expected so I guess its always good to have separate tests if some one wants to execute testsng tests in a particular sequence. Thanks again.

On Sunday, 19 January 2014 04:00:09 UTC, talon wrote:
try specifying @Priority(n), ... for each test based on how you need them to run.


On Friday, January 17, 2014 2:59:04 PM UTC-6, Kiran wrote:
Hi,

I have a testng class which has 6 test methods in it. I would like to execute the methods in a particular order since each test depends on its previous test. I see the first two tests are executing in sequence[i.e abNavigateTest and addAdvGroup - please see below testng.xml] but testng ignores the 3rd test(addAdvt) and picks the 4th test instead. I assume Testng executes tests in alphabetical order and maintains the order specified in testng.xml. 

I have tried setting preserve-order=true and setting priority for each test but it appears to be not working for my case. Sorry, I am sure but it might have worked for others! I also would like to avoid using dependsOnMethods.

Could some one please have look on this ? I am not sure what else I need to add to make testng to run the tests in the order specified in testng.xml ? Please find below the testng.xml, test details and let me know if you need more details. Thank you!



testng.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "<a href="http://testng.org/testng-1.0.dtd" target="_blank" onmousedown="this.href='http://www.google.com/url?q\75http%3A%2F%2Ftestng.org%2Ftestng-1.0.dtd\46sa\75D\46sntz\0751\46usg\75AFQjCNFHihXzQ1YlwcxcDehnw97TuniFLA';return true;" onclick="this.href='http://www.google.com/url?q\75http%3A%2F%2Ftestng.org%2Ftestng-1.0.dtd\46sa\75D\46sntz\0751\46usg\75AFQjCNFHihXzQ1YlwcxcDehnw97TuniFLA';return true;">http://testng.org/testng-1.0.dtd">
<suite name="MDM Smoke Tests" >
<listeners>
<listener class-name="org.uncommons.reportng.HTMLReporter" />
<listener class-name="org.uncommons.reportng.JUnitXMLReporter" />
</listeners>
<test verbose="2" name="MDM Smoke Tests">
<classes>
<!-- <class name="com.mdm.functional.test.AgencyTest"/> -->
<class name="com.mdm.functional.test.MDMOrgTest" >
<methods>
<include name="abNavigateTest" />
<include name="addAdvGroup" />
<include name="addAdvt" />
<include name="addBrand" />
<include name="addProduct" />
<include name="Budget" />
<include name="BudgetLine" />
</methods>
</class>
<!-- <class name="com.mdm.functional.test.PublisherTest"/> -->
</classes>
</test>
</suite>


Test file will looks like this

package com.mdm.functional.test;


import java.net.URL;
import java.util.HashMap;

import org.apache.log4j.Logger;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;



public class MDMOrgTest extends MdmTestBase {

@BeforeTest
public void init(){
}
@Test()
public void abNavigateTest()
{
}
@Test(dataProvider = "OrganisationData")
public void addAdvGroup(HashMap<String, String> orgData)
{
}
@Test(dataProvider = "OrganisationData")
public void addAdvt(HashMap<String, String> orgData)
{
}
@Test(dataProvider = "OrganisationData")
public void addBrand(HashMap<String, String> orgData)
{
}
@Test(dataProvider = "OrganisationData")
public void addProduct(HashMap<String, String> orgData)
{
}
@Test(dataProvider="budgetData")
public void Budget(HashMap<String, String> orgData)
{
}
@Test(dataProvider="budgetLineData")
public void BudgetLine(HashMap<String, String> orgData)
{
}
@DataProvider(name = "OrganisationData")
    public Object[][] organisationData() throws Exception 
    {
    }
@DataProvider(name="budgetData")
public Object[][] budgetData() throws Exception
{
}
@DataProvider(name="budgetLineData")
public Object[][] bugetLineData() throws Exception
{
}
private  Object[][] readyOgData(String sheetName){
}
private  Object[][] readBudgetData(String sheetName){
}
private  Object[][] readBudgetLineData(String sheetName){
}
}




--
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 http://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/groups/opt_out.