Create the other unit test files (test cases) in same package as image be shown below
You need to create all test cases in same package after that you need to create a runner class for run the all test cases as test suit. Now we think how to run the separate junit files .... :-/
we can create a runner file for run all test case .
The runner java file be shown below
package search.test;
import org.junit.internal.TextListener;
import org.junit.runner.JUnitCore;
public class Runner {
public static void main(String[] args) {
JUnitCore runner = new JUnitCore();
System.out.println("test Suite results..");
runner.addListener(new TextListener(System.out));
runner.run(search.class,searchFB.class);
}
}
The image be shown below ..
After that you export the project as Runnable JAR file. Right click your project and click the export link to create below images are shown
Make sure launch configuration and Export Destination.
After creating the jar file run the selenium RC server in command prompt and run the export jar file in another command prompt ,
command :
java -jar <test suite name>.jar
Enhancement
Create a properties file for Server Name , Browser, Base URL and Port No.it should be easy for change the server name and other things. Properties file be shown below
config.properties
server= localhost
browser= *firefox
Url= http://www.google.lk/
And change the each and every test cases /junit file
public void setUp() throws Exception {
try {
File file = new File("config.properties");
FileInputStream fileInput = new FileInputStream(file);
Properties properties = new Properties();
properties.load(fileInput);
fileInput.close();
serv=properties.getProperty("server");
brow=properties.getProperty("browser");
url=properties.getProperty("Url");
}
catch (Exception e1) {
e1.printStackTrace();
}
selenium = new DefaultSelenium(serv, 4444, brow, url);
selenium.start();
}
Just because something doesn't do what you planned it to do doesn't mean it's useless.
-Thomas Alva Edison
-Thomas Alva Edison
0 comments:
Post a Comment