开发者

What is the right java unit test library for http?

I am developing a servlet application, I was using JWebUnit, to check all the basic responses, but now I have to start using other HTTP methods different to GET(POST,PUT and DELETE).

So, I found HttpUnit, it looks that have support for what I need, POST and PUT methods are available there and I guess I can walk around the DELETE method through the HEAD which is supported by HttpUnit.

However I found there开发者_如何学运维 is no recent activity in this project; the last release was about two years ago. so my question is if there is any other library that people is using for it or HttpUnit is the right for my case?

Thanks.


Httpunit is a mature library. It works just fine for what you are trying to do.


I recommend HtmlUnit instead. No disrespect intended towards HttpUnit: I used it a few years ago and it worked well. However it died as a project for a number of years, and more particularly it had little support for Javascript, so I switched to HtmlUnit

HtmlUnit has been steadily developed since its inception and has exceptional Javascript support. I have used it to test sites containing a lot of Ajax and only once, I think, did it not properly execute the JS code (turned out to be a wee HtmlUnit bug, which I fixed). There are a lot of hooks available to help you test what's going on.

As well, as the site says, "HtmlUnit is used as the underlying 'browser' by different Open Source tools like Canoo WebTest, JWebUnit, WebDriver, JSFUnit, Celerity, ..." I haven't used those, as I prefer expressing my tests in Java, but I understand HtmlUnit works well for them.


Agreed with @Sasi.

It should also be noted that there are occasional checkins to the project's SVN repository. The most recent were a couple of months ago to apply a contributed patch for a bug. So there are still developers taking care of the code.


You can try out REST Assured which makes it very simple to make http requests and validate the response in Java.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜