Re: HtmlUnit



kalensr wrote:

> Recently I have been working with Junit and HttpUnit. I have
> successfully implemented a suite of tests and I am pleased with the
> results.
>
> However, in my R&D I came across HtmlUnit
> http://htmlunit.sourceforge.net/ and I am very interested in moving
> forward with this API.
>
> I have found very few examples and no user groups that discuss the
> usage of HtmlUnit.
>
> I am looking for someone who has experience writing tests with HtmlUnit
> or someone who can direct me to other resources. I have come across a
> few road blocks early on in my exploration of HtmlUnit.

Samie, Pamie, Watir, JSUnit, Selenium, and HttpUnit are its competition,
among many others.

HtmlUnit is an interesting concept. Some of those testers live in Internet
Explore and operate its DOM and/or JavaScript. HttpUnit mocks a web browser,
and feeds raw HTTP to a web server. HtmlUnit, IIRC, only reads HTML. If so,
it leaves HTTP out of the loop (and hence also the CGI/Servlet layer), and
it works by interpretting the HTML. It mocks a web browser, and allows
high-level queries into the objects that a web browser would have rendered.

Now let's throw another hat in the fire. Suppose your HTML is pure XHTML
(which is a very good idea, never ever to rely on "browser forgiveness").
Then you can use XPath for high-level queries of the HTML contents.
//textarea/[text()='sauromatians'] will only return a node if it finds a
<textarea> element containing that text.

All these tools are fun to use, and many can propel development very easily.
Don't use them to avoid writing low-level tests. Directly testing the
function that supplies "sauromatians" for that <textarea> has many benefits
over testing that the HTML layer generated the correct <textarea>, /and/ an
HTTP server transmitted it, AND a web browser collected it, /AND/ its DOM
layer rendered it correctly.

--
Phlip
http://www.greencheese.org/ZeekLand <-- NOT a blog!!!


.



Relevant Pages

  • Re: HtmlUnit
    ... > Recently I have been working with Junit and HttpUnit. ... limited and needed to drop down to using rhino and httpunit. ... Someone else at my site suggested htmlunit. ... darrell dot grainger at utoronto dot ca ...
    (comp.software.testing)
  • Re: HtmlUnit - handling client side redirect
    ... I thought HtmlUnit simply parsed and tested HTML. ... addition to it that also drives Internet Explorer to hit a real web server. ... HTTPUnit uses the web's native decoupling, ...
    (comp.software.testing)
  • HtmlUnit - handling client side redirect
    ... Below I have posted some examples of both successfully handling client ... Client side redirect indicated by: ... Handled in HttpUnit like such: ... Attempting to perform same actions in HtmlUnit: ...
    (comp.software.testing)
  • HtmlUnit (or HttpUnit) - Javascript and iFrames
    ... I am wondering if anyone has experience working with js and iframes in ... httpunit or htmlunit? ... The application I am working with has multiple iframes that get loaded ... I am wondering how difficult it is to do simple js calls from httpUnit ...
    (comp.software.testing)
  • Re: Unittesting for web applications
    ... Httpunit and Htmlunit, ... of variants. ... > unittests for web applications? ...
    (comp.lang.python)