Thursday, August 5, 2010

Testing rich webapps from JUnit with Rhino and Envjs

Envjs is an implementation of the DOM in Javascript. Together with Rhino, it can function as a headless web browser in Java. Picture HtmlUnit, but with flawless Javascript support. For instance, the latest version of JQuery works flawlessly in Envjs on Rhino but won't even load in HtmlUnit.

Here's a simple way to tie them together in JUnit. Wonderful testing frameworks to follow (looking at you, Mike ;)

Not too many Groovy-isms here, can easily be converted to plain Java.

No comments: