TestNgxml executes 3rd class first | Selenium Forum
A
Ankit Lohia Posted on 19/03/2019

Hi All,

I have created a POM framework and I have been experiencing an issue where in testNg.xml I have 3 classes->

<?xml version = "1.0" encoding = "UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name="FREE CRM POM FRAMEWORK">

<listeners>
<listener class-name="com.crm.qa.extentreport.ExtentReportListener" />
</listeners>


<test name="EXECUTING ALL TESTS">

<classes>
<class name="com.crm.qa.testcases.LoginPageTest" ></class>

<class name="com.crm.qa.testcases.HomepageTest" ></class>

<!-- <class name="com.crm.qa.testcases.ContactspageTest" ></class> -->


</classes>
</test>


</suite>

 

Now if I Run this above My output will be 

LoginPageTest runs first

HomepageTest runs second

 

But when I uncomment the ContactspageTest Output will be->

ContactspageTest Runs first

LoginPageTest runs second

HomepageTest runs third

 

Contactspage Test should run at last.. pls help


A
Ashish Thakur Replied on 19/03/2019

please share the error stack trace


A
Ankit Lohia Replied on 19/03/2019

There is no error stack appears.. kindly check below few test are pending to run.

Responsive image

A
Ankit Lohia Replied on 19/03/2019

Resolved. The error was in ContactspageTest.java

I havn't provided priority to one of the Testcases in this class. So testNg was executing this particular testcase very firstly. Like if there are 4 TC

@Test(priority=1)

public void test1(){

}

 

@Test(priority=2)

public void test2(){

}

 

@Test(priority=3)

public void test3(){

}

 

@Test()

public void test4(){

}

So in this case test4 was executing very first... I want to know does that happens. I have encountered this scenario first time. Either we provided priority to all TC or not . please clarify


A
Ashish Thakur Replied on 20/03/2019

If there is no priority provided, testng will consider the function as higher priority