Suite creation in Junit4
First Test
Second Test
Suite Class
First Test
package com;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.openqa.selenium.server.SeleniumServer;
import com.thoughtworks.selenium.DefaultSelenium;
import com.thoughtworks.selenium.Selenium;
public class FirstOne {
private static SeleniumServer seleniumServer;
private static Selenium selenium = new DefaultSelenium( "localhost",4444, "*chrome","http://www.google.com");
@BeforeClass
public static void setUpBeforeClass() throws Exception {
seleniumServer = new SeleniumServer();
seleniumServer.start();
selenium.start();
}
@AfterClass
public static void tearDownAfterClass() throws Exception {
selenium.stop();
seleniumServer.stop();
}
@Test
public void Testing() throws Exception{
selenium.open("/");
selenium.waitForPageToLoad("6000");
selenium.type("q", "search");
selenium.click("btnG");
}
}
Second Test
package com;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import org.openqa.selenium.server.SeleniumServer;
import com.thoughtworks.selenium.DefaultSelenium;
import com.thoughtworks.selenium.Selenium;
public class SecondOne {
private static SeleniumServer seleniumServer;
private static Selenium selenium = new DefaultSelenium( "localhost",4444, "*chrome","http://www.google.com");
@BeforeClass
public static void setUpBeforeClass() throws Exception {
seleniumServer = new SeleniumServer();
seleniumServer.start();
selenium.start();
}
@AfterClass
public static void tearDownAfterClass() throws Exception {
selenium.stop();
seleniumServer.stop();
}
@Test
public void Testing() throws Exception{
selenium.open("/");
selenium.waitForPageToLoad("6000");
selenium.type("q", "selenium");
selenium.click("btnG");
}
}
Suite Class
package com;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
@RunWith(Suite.class)
@Suite.SuiteClasses({FirstOne.class, SecondOne.class})
public class TestSuite {
//nothing
}
No comments:
Post a Comment