Automating Assembly and Integration Tests with HtmlUnit

With this blog entry I want to start a mini-series about automating assembly and integration tests in Java. Mini-series because there are many different tools and techniques to choose from, and depending on the software being developed you will choose and combine to get the best results.

This entry will show the basics on how to use HtmlUnit to automate assembly and integration tests of web applications.

What is HtmlUnit? HtmlUnit is a framework that runs on top of the popular JUnit testing framework that simulates a web browser, including JavaScript. Using the HtmlUnit API you can interact with the web pages and get insights of the layout and contents to write assertions. An interesting fact about HtmlUnit is that you can use to automate tests of web applications written in other languages than Java.

HtmlUnit can be downloaded from the tool web site at http://htmlunit.sourceforge.net/.

With HtmlUnit there is no practical distinction when you intend to write an assembly or an integration test case. If you choose to run with an embedded (or in memory) database and web application server or with a dedicated one will mark the (sometimes controversial) distinction between an assembly or an integration test.

In this entry we are focusing on HtmlUnit setup and common use cases and for a later entry we will focus in assembly vs. integration setup, best practices and how to run them within a continuous build/integration process.

Continue reading “Automating Assembly and Integration Tests with HtmlUnit”

Advertisements