How to Maven JUnit-test HTML pages containing Javascript and calling a servlet?

I am still new to Javascript and Servlets. I have some HTML pages containing javascript code and these pages can call a servlet. I want to develop JUnit-like test for this page to run from Maven.

I googled and found JSUnit to test Javascript and HttpUnit to test Servlets, but how can I test my HTML page by simulating clicks and user actions? Is there a framework to write these tests in a Java/JUnit fashion? Basically, I want to automate these as part of a maven compilation process.

Upvotes: 0

Views: 799

Answers (2)

Dave Newton
Dave Newton

Reputation: 160181

I use a combination of JWebUnit as the driver and easyb for writing specifications.

JWebUnit will drive either HtmlUnit or Selenium. This is both good and bad; good because the behavioral tests can run on a headless server via HtmlUnit, bad because I lose some functionality of HtmlUnit in the process... some tests "go native". Pretty good JavaScript support, too.

Upvotes: 1

Brian Hoover
Brian Hoover

Reputation: 7991

Have you looked at Selenium and Watir? Selenium can capture the clicks and then be put into a jUnit framework to run like it was unit tests. Watir does the same type of thing in Ruby.

Upvotes: 2

Related Questions