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?
- 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
- 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.
- JUnit in Action, Second Edition