用cactus,jetty实现对servlet类进行单元测试一
Cactus provides several TestCase classes that extends the JUnit Testcase and it also provides several kind of redirectors (Servlet Redirector, JSP Redirector, ...). The diagram above is a generic diagram which serves to explain the principles. You'll find details for a specific redirector proxy in the next section. YYYTestCase = ( ServletTestCase | FilterTestCase | JspTestCase ) XXX is the name of the test case. Each YYYTestCase class contains several test cases
这是官网的简单说明,意思是:cactus提供了几个TestCase的类扩展了JUnit的TestCase的,同时也提供了若干种转向器(重定向程序组件,JSP的重定向,...).上图是一个普通的图,这足以解释的原则。你会发现,在未来一段特定的重定向代理细节。 YYYTestCase =(ServletTestCase | FilterTestCase | JspTestCase)XXX是测试案例的名称。每个YYYTestCase类包含几个测试案例。
我们将使用Cactus的ServletTestRedirector作为上图介绍的Redirector Proxy,并使用Cactus的ServletTestRunner作为执行测试时的TestRunner,这两个被撰写为Servlet,所以要在web.xml中加以定义,代码为:
? </web-app>