Cactus借助Jetty测试Servlet (三)

2014-11-24 10:16:47 · 作者: · 浏览: 2
Unit4中的annotation
* @see 所以为了实现类似@BeforeClass的功能,我们就借助JUnit3.8中测试套件,最后测试时直接运行此测试套件即可
* @see 关键JUnit3.8和JUnit4的测试套件编写规则,详见http://blog.csdn.net/jadyer/article/details/6013743
* @create Jul 5, 2013 4:05:00 PM
* @author 玄玉
*/
public class TestAllUseJetty {
public static Test suite(){
//此时就不需要cactus.properties文件了,并且注意这里的值就不能以下划线结尾了,而端口则可任意设定
//另外在web.xml中也不需要配置org.apache.cactus.server.ServletTestRedirector及其映射了
System.setProperty("cactus.contextURL", "http://127.0.0.1:8088/testJettyAndCactus");

TestSuite suite = new TestSuite();

suite.addTestSuite(LoginServletTest.class);

//记得要引入org.mortbay.jetty-5.1.9.jar,否则会报告java.lang.ClassNotFoundException: org.mortbay.jetty.Server
return new Jetty5xTestSetup(suite);
}
}