I spent a little bit of time check out both webtest and jWebUnit. Here are my first impression:
webtest is declarative and XML configuration file driven. If you like configuration management more than programming, you might like this format. All you need is edit the test definition and hit the run command, no compilation necessary. If you have well formed HTML and working JavaScript, then you should not have too much trouble running this. My initial simple test case works once I commented out the non-working and irrelevant JavaScript reference in the HTML. I tried to take another mini-step forward by attempting to “configure” a click to select one of the link items in a JavaScript widget. Webtest has 3 ways to click on a link, by ID, label, or xPath. The widget’s link item doesn’t have an ID, so I can’t use that. I tried label and that didn’t work. Then I tried xPath and that didn’t work for me either. So, that second mini-step didn’t go very far for me. Any one know an open source xPath validation tool or web site?
jWebUnit is one of the many unit testing frameworks based on jUnit/HtmlUnit. The interesting aspect of this framework is that it supports both HtmlUnit and Selenium test cases. jWebUnit uses similar programmatic model as jUnit, so you can stay comfortable within your favorite IDE. I was able to create a new project in NetBeans and leverage it’s jUnit feature, by creating an unit test and rewrite that as a jWebUnit test case, while using NetBeans to drive the test execution. jWebUnit, or the underlying HtmlUnit engine appears more picky about JavaScript than Webtest, I had to start tweaking YUI libraries in an attempt to load a page, which shouldn’t be something that I supposed to be doing anyway. Perhaps YUI engineers use a different unit testing framework. The test page actually loads without a major issue in Firefox.
Both frameworks do share one thing in common, both do not use actual browser instances to drive the testing. And that explains why they don’t work as well as some of testing frameworks that built within or on the real browser instance because of behavior differences when processing JavaScript. At the same time, both may have one advantage over browser based testing framework, which is the ability for non-interactive testing through ant and is very useful for continuous integration servers such as CruiseControl. Again, I’ve only looked a few testing frameworks and let me know if you know a browser based unit testing framework that works with ant. Thanks.
Hey,
You might want to check out YUI Test, our new testing framework we released last week.
Thanks,
Nate
Hi Nate,
Thanks for your pointer. I’ll check it out.
Hi Nate,
Looks like YUI Test doesn’t integrate with ant, right? i.e. trigger the unit tests via ant.
The tests live within the JS itself. We start the testing as part of our build process (not using ant, but should be doable I think).
Feature requests and bug reports are encouraged!:
http://developer.yahoo.com/yui/articles/reportingbugs/
Thanks,
Nate
faint, YUI is for Javascript, man.
Aren’t we talking about Java?
Hi Teaman,
Yes. YUI is a JavaScript framework/library/widget library. I was talking about testing a web application, which may contain JavaScript. So, the need to test against the functionality of an integrated complete web app was part of the expectation when I wrote the blog entry.
Hi,
I’m taking a look to the web app testing framweworks and I was wondering if you have more frameworks comparison resources like this post ?
thanks