The comparison of HtmlUnit, HttpUnit and Selenium and tool’s selection

In last months, I have done some research on different test tools including JUnit, HttpUnit, HtmlUnit and Selenium to figure out which tool is better for us to test VIA project. Finally, I think that Selenium is a suitable tool for us to test Web Pages of Avaya VIA project. The reasons are as following.

HttpUnit is a suite of Java classes to test Web applications over HTTP. It is written in Java and it emulates the relevant portions of browser behavior, including form submission, JavaScript, basic http authentication, cookies and automatic page redirection, and it allows Java test code to examine returned pages as containers of forms, tables, and links. It can also be combined with a JUnit testing framework and it is fairly easy to write tests that very quickly verify the functioning of a web site. Actually, it is a very good tool to test Web applications.

The only reason that we dismiss it is that it does not support all features of the Java Script, while most part of Web Pages of VIA project is written with Java Script.

HtmlUnit, similar with HttpUnit, works based on JUnit framework too and is targeted at Web Application testing.The biggest difference between HtmlUnit and HttpUnit is the style of writing test cases. HttpUnit centers itself on the protocol, we can create requests and send them to the server no matter it is Html, serverlet or Jsp page on the server side; whereas HTMLUnit is more HTML friendly. You can ask an HtmlPage for Html Anchors and click them or you can set the values for Text Inputs, select box and submit the inputs.

At first, I think that HtmlUnit will support Java Script well than HttpUnit. But, as research is going on, I found out that both of HtmlUnit and HttpUnit are using Rhino to support Java Script. Rhino is an open-source implementation of JavaScript written entirely in Java and it is typically embedded into Java applications to provide scripting to end users. So, on the point of supporting Java Script HtmlUnit is same with HttpUnit and it cannot support all features of Java Script in VIA project.

Selenium is a test tool for web applications. Selenium tests run directly in a browser, just as real users do. And they run in Internet Explorer, Mozilla Firefox on Windows, Linux, and Macintosh. With Selenium, we can test our application to see if it works correctly on different browsers and operating systems. And we can also create regression tests to verify application functionality and user acceptance.Selenium uses JavaScript and Iframes to embed a test automation engine in your browser. This technique should work with any JavaScript-enabled browser such as Explorer 6.0, Firefox1.5 on windows platform.

It is because that selenium supports all Java Script features that explorer supported that we select selenium as our test tool to do testing for Web Pages of VIA project.

If we intend to generate test cases automatically, we should also use HttpUnit or HtmlUnit to retrieve the controls on Web Pages, analyze the features of them and create Selenium style test cases.