public class mytestcase extends testcase {
/**
* call super constructor with a test name
* string argument.
* @param testname the name of the method that
* should be run.
*/
public mytestcase(string testname){
super(testname);
}
/**
* called before every test
* 在每项测试开始前被调用
*/
protected void setup() throws exception {
initsomething();
}
/**
* called after every test
* 在测试完成后被调用
*/
protected void teardown() throws exception {
finalizesomething();
}
/**
* this method tests that ...
* 这个方法测试……
*/
public void testsometest1(){
...
}
/**
* this method tests that ...
* 这个方法测试……
*/
public void testsometest2 (){
...
}
}public class mytestsuite extends testsuite {
public static test suite() {
testsuite suite =
new testsuite("test suite for ...");
// add the first test
// 添加第一个测试
mytestcase mtc =
new mytestcase("testsometest1");
suite.addtest(mtc);
// add the second test
// 添加第一个测试
mytestcase mtc2 =
new mytestcase("testsometest2");
suite.addtest(mtc2);
return suite;
}
}#!/bin/sh
# the folder were the agent can find junit.jar
export junit_home=/opt/junit3.8.1
# the folders were the agent can find
# the junit tests
export junit_test_classpath=../examples/
# the multicast port that the communication
# layer uses
export pisces_mcp=6767
# the multicast ip that the communication
# layer uses
export pisces_mcip=228.4.19.76
# the unique name of the agent
export agent_name=remote1
java -classpath
"$junit_home/junit.jar:../pisces.jar:$junit_test_classpath" \
org.pisces.remotetestrunneragent \
-name $agent_name -com multicast \
-mcp $pisces_mcp -mcip $pisces_mcip
// create the multicast communication layer
multicastremotetestcommunicationlayer com =
new multicastremotetestcommunicationlayer(
remotetestrunner.name ,"228.4.19.76",6767);
// set the communication layer
remotetestrunner.setcom(com);
// 创建一个通常的testsuite实例
testsuite suite =
new testsuite("test for org.pisces.testers");
// 为这个实例创建一个包装器
remotetestcase rtc =
remotetestcase.wrap(remotetesttestcase.class
,"sometestmethod", "remote1");
// 添加测试实例到testsuite
suite.addtest(rtc);
public class remotetestsuiteexample extends testsuite {
public static test suite() {
// 配置并启动通信层
jmsremotetestcommunicationlayer com = null;
try {
com =
new jmsremotetestcommunicationlayer
(remotetestrunner.name,
new mantaconnectionfactory());
} catch (jmsexception e) {
throw new runtimeexception(e);
}
remotetestrunner.setcom(com);
// 实例化junit
testsuite suite =
new testsuite("test for org.pisces.testers");
// 在远程代理remote1上运行mytestcase类中的testlogin remotetestcase rtc =
remotetestcase.wrap(mytestcase.class,
"testlogin", "remote1");
suite.addtest(rtc);
// 在远程代理remotel2上运行mytestcase类中的
// testloginfails方法
remotetestcase rtc1 =
remotetestcase.wrap(mytestcase.class,
"testloginfails", "remote2");
suite.addtest(rtc1);
return suite;
}
}Java Asp PHP .Net XML C/C++ CGI VB Jsp J2ee J2se J2me EJB Servlet Tomcat Resin Struts Weblogic Eclipse ANT GUI JMS Web servise IDEA Webphere Hibernate Spring Jboss Applet Swing Socket Javamail Perl Ajax P2P 安全 模式 框架 测试 开源 游戏
Windows XP Windows 2000 Windows 2003 Windows Me Windows 9.x Linux UNIX 注册表 操作系统 服务器 应用服务器