Most testing frameworks have the concept of grouping a set of text fixtures into a ’suite’ so that you can execute a number of related tests together.
Creating test suites with Selenium doesn’t appear to be obvious at first. Here’s a simple guide on how to create and execute suites of functional tests:
Here i am using Junit scripts and Test suite()
First create two scripts....Ex:Google1 and Google2
Google1.java
------------------------------------------------------------
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.server.*;
import com.thoughtworks.selenium.DefaultSelenium;
import com.thoughtworks.selenium.SeleneseTestCase;
import com.thoughtworks.selenium.Selenium;
public class Google1 extends SeleneseTestCase{
private Selenium selenium;
private SeleniumServer seleniumServer;
@Before
public void setUp() throws Exception {
selenium = new DefaultSelenium("localhost", 4444, "*firefox", "http://");
seleniumServer = new SeleniumServer();
seleniumServer.start();
selenium.start();
}
@After
public void tearDown() throws Exception {
selenium.stop();
seleniumServer.stop();
}
@Test
public void testText1() throws Exception {
selenium.open("http://www.yahoo.com");
selenium.windowMaximize();
}
}
------------------------------------------------------------
Google2.java
------------------------------------------------------------
package defaultpackage;
import org.openqa.selenium.server.SeleniumServer;
import com.thoughtworks.selenium.DefaultSelenium;
import com.thoughtworks.selenium.SeleneseTestCase;
import com.thoughtworks.selenium.Selenium;
public class Google2 extends SeleneseTestCase{
private Selenium selenium;
private SeleniumServer seleniumServer;
public void setUp() throws Exception {
selenium = new DefaultSelenium("localhost", 4444, "*iehta", "http://");
seleniumServer = new SeleniumServer();
seleniumServer.start();
selenium.start();
}
public void tearDown() throws Exception {
selenium.stop();
seleniumServer.stop();
}
public void testText2() throws Exception {
selenium.open("http://www.google.com");
selenium.windowMaximize();
}
}
------------------------------------------------------------
Here is the test suite....TestSuite1.java
------------------------------------------------------------
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
import junit.textui.TestRunner;
public class TestSuite1 extends TestCase {
public static Test suite()
{
TestSuite nag = new TestSuite();
nag.addTestSuite( Google1.class);
nag.addTestSuite( Google2.class);
return nag;
}
public static void main(String arg[])
{
TestRunner.run(suite());
}
}
------------------------------------------------------------
Run the TestSuite1.java script ...it will automatically run the Google1 and Google2....
Even though first test case is failed it will run the second one....we can change the order of the test cases...
December 15, 2010
Test Suite using JUnit....
Tags
# JUnit
# selenium RC
About Naga
Soratemplates is a blogger resources site is a provider of high quality blogger template with premium looking layout and robust design. The main mission of templatesyard is to provide the best quality blogger templates.
Test Suite
Labels:
JUnit,
selenium RC,
Test Suite
Subscribe to:
Post Comments (Atom)
Hi Nag,
ReplyDeleteYou are really awesome in explaining selenium... I thank you so much for the stuff you are giving out through this blog and like to follow up with you in the future as well... hope you will be there for any doubts !!
Regards,
Fayaz
Hi naga,
ReplyDeletecan we run the suite using testNG just as junit?
Hello, I have testsuite ready and it is running, but I need to generate reports.. could you please help me
ReplyDeleteyou can also creae Suite as below
ReplyDeleteimport org.junit.runner.RunWith;
import org.junit.runners.Suite;
import org.junit.runners.Suite.SuiteClasses;
@RunWith(Suite.class)
@SuiteClasses({Login.class,Upload.class})
public class MyTestSuite {
}
Pandora Charms Outlet
ReplyDeletePandora Official Site
Pandora Charms
Red Bottom Shoes
Nike Air Max 270
Yeezy boost 350 v2
Air Jordan 4
Air Jordan
Jordan Retro
Kyrie 3 Shoes
Rodney20181008