如何为Servlet测试创建虚拟请求和响应。我阅读了关于Apache Jkarta Cactus项目的内容,但不想详细说明。 我们是否可以构造一个虚拟请求响应并将其传递给do()方法(Ofcourse构造的请求将具有URL和请求参数,但是如何构造这种虚拟请求)?
并且也希望junit不依赖于Apache(应该独立于它运行)。
How to Create a Dummy Request and Response for Servlet Testing.I read about the Apache Jkarta Cactus Project but do not want to go in that much details. Can we just construct a dummy request response and pass it to doGet() method (Ofcourse the request constructed would have a URL and request parameters, but how to construct such dummy request)?
and also want no dependency of junit on Apache(should run independent of it).
最满意答案
看看MockHTTPServletRequest(),我认为它会起作用。 这里是你可以阅读的链接。
Look into MockHTTPServletRequest(), I think its going to work. Here is the link which you can read.
更多推荐
发布评论