20 November, 2012

Testing Web Presentation Layer using HtmlUnit - Part I

Presentation-layer testing means finding bugs in the graphical user interface (GUI) of a web application and portlets.

What is HtmlUnit?
HtmlUnit is an open source Java headless browser framework. It allows tests to imitate programmatically the user of a browser-based web application including portlets. HtmlUnit tests don’t display a user interface. The framework lets you test all aspects of a web application.

In the HtmlUnit context “testing with a web browser,” actually means that we’re testing by emulating a specific web browser.


When to use HtmlUnit?
HtmlUnit is a 100 percent Java headless browser framework that runs in the same virtual machine as your tests. Use HtmlUnit when your application is independent of operating system features and browser-specific implementations not accounted for by HtmlUnit, like JavaScript, DOM, CSS, and so on.

Benefits

  • More efficient than manual testing
  • Less error prone than manual testing
  • Enables collective code ownership
  • Enables refactoring
  • Enables frequent integration
  • Enables browser-specific testing  with less effort
Summary
  • HtmlUnit is a 100 percent Java solution with no external requirements; it offers a complete HTML object model, which, although creating rather verbose test code, offers great flexibility. 
  • Use HtmlUnit when your application is independent of operating system features and browser-specific implementations of JavaScript, DOM, CSS, and so on.

References

  • http://htmlunit.sourceforge.net/
  • JUnit in Action, Second Edition

No comments:

Post a Comment