Reputation: 91
I am trying to run my TestNG suite with testng.xml. I have total four classes in my suite but I am only able to run two classes at a time with all methods. Suppose I have 3 methods in each class, so in TestNG suite if I add only two classes, testng.xml file will run my both tests with 6 methods. Now if I try to add 3rd class in my testng.xml file, it will run only first method from each class. it means now it is running only 3 methods( one from each class).I have created a source folder under my project and then created this testng.xml file inside this source folder. Would you please let me know what I am doing wrong. Below is my testng.xml file and test cases.
testng.xml is below:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="MurcuryTour AUtomation suite">
<test name="MurcuryTour">
<classes>
<class name="murcuryTourPagesTests.LoginPageTest"></class>
<class name="murcuryTourPagesTests.FlightsPageTest"></class>
<class name="murcuryTourPagesTests.HomePageTest"></class>
</classes>
</test>
</suite>
Upvotes: 0
Views: 442
Reputation: 91
Here is my all test classes that I am trying to run in test suite.
package murcuryTourPagesTests;
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import com.MurcuryTour.qa.base.TestBase;
import com.MurcuryTour.qa.pages.FlightsPage;
import com.MurcuryTour.qa.pages.LoginPage;
public class LoginPageTest extends TestBase{
LoginPage loginpage;
FlightsPage flightspage;
public LoginPageTest() {
super();
}
@BeforeClass
public void setup() {
initialization();
loginpage = new LoginPage();
flightspage = new FlightsPage();
}
@Test(priority=1)
public void titleVerification() {
String title =loginpage.validatePageTitle();
Assert.assertEquals(title,"Sign-on: Mercury Tours");
}
@Test(priority=2)
public void login() {
flightspage =loginpage.login(prop.getProperty ("username"),prop.getProperty("password"));
}
@AfterClass
public void tearDown() {
driver.quit();
}
}
-----------------------------------------------------------
2nd class:
package murcuryTourPagesTests;
import org.testng.Assert;
import org.testng.annotations.AfterSuite;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
import com.MurcuryTour.qa.base.TestBase;
import com.MurcuryTour.qa.pages.HomePage;
import com.MurcuryTour.qa.pages.LoginPage;
import com.MurcuryTour.qa.pages.RegistrationPage;
public class HomePageTest extends TestBase {
LoginPage loginpage;
HomePage homepage;
RegistrationPage registrationPage;
public HomePageTest() {
super();
}
@BeforeTest
public void setup() {
initialization();
loginpage = new LoginPage();
loginpage.login(prop.getProperty("username"),prop.getProperty("password"));
homepage = new HomePage();
registrationPage = new RegistrationPage();
}
@Test(priority = 1)
public void click_On_Home_Tab() {
homepage.Click_On_Home_Tab();
}
@Test(priority = 2)
public void home_Page_Title_Verification() {
String title = homepage.Verify_HomePage_Title();
Assert.assertEquals(title, "Welcome: Mercury Tours");
}
@AfterSuite
public void tearDown() {
driver.close();
}
}
---------------------------------------------------------------------
3rd class:
package murcuryTourPagesTests;
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import com.MurcuryTour.qa.base.TestBase;
import com.MurcuryTour.qa.pages.FlightsPage;
import com.MurcuryTour.qa.pages.HomePage;
import com.MurcuryTour.qa.pages.LoginPage;
public class FlightsPageTest extends TestBase{
LoginPage loginpage;
FlightsPage flightspage;
HomePage homepage;
public FlightsPageTest() {
super();
}
@BeforeClass
public void setup() {
initialization();
loginpage= new LoginPage();
loginpage.login(prop.getProperty("username"),prop.getProperty ("password"));
flightspage= new FlightsPage();
homepage= new HomePage();
}
@Test(priority=1)
public void verifyFlightsPageTitle() {
String title =flightspage.varifyFlightsPageTitle();
Assert.assertEquals(title,"Find a Flight: Mercury Tours:");
}
@Test(priority=2)
public void move_To_Find_A_FlightPage() {
flightspage.clickOnFindFlights();
}
@Test(priority=3)
public void move_To_Reservation_Page(){
flightspage.clickOnreserveFlights();
}
@Test(priority=4)
public void enter_User_Inofrmation() {
flightspage.enterUserInformation();
}
@Test(priority=5)
public void back_To_Home_Page(){
homepage=flightspage.backToHomePage();
}
@AfterClass
public void tearDown() {
driver.quit();
}
}
Upvotes: 0