Matt Wynne wrote:
Interesting. On the surface HtmlUnit looks just like webrat - what's the difference?
HtmlUnit is quite different. It is a language/framework agnostic way to test any webapp *including* the app's JS. All of this, even the JS, is in memory and does not require a browser just like webrat. It does the JS by using Rhino, Java's implementation of JS. At the moment, webrat is tied to rails integration testing framework (their are forks that allow merb testing as well that I have used successfully.) As Joseph said their is currently some work to wrap the webrat API around Selenuin, mechanize, etc, that would break it's dependence on the integration testing framework in rails. Having it tied to the integration framework does give you some flexibility though and is most likely faster.

To answer your original question on how people are using it... In the past project I did I ended up with 100+ scenarios all using webrat. We decided to make the entire site with UJS (unobtrusive JS) which lent it self to testing it with webrat. The extra JS we added we have not yet wrapped stories around it so we have a manual testing cycle before each major deployment. On the current project I'm on we are going to be using JS heavily and will most likely leverage HtmlUnit (Celerity) in our stories to keep them all in-memory. If your app is not extremely JS dependent then I would recommend the UJS + webrat route.


@Joseph
If you are using JRuby a nice tool which wraps the Java HtmlUnit is
Celerity:
http://celerity.rubyforge.org/

At the moment I'm yet to see something like HtmlUnit on the ruby
platform. I watch Celerity in envy :)

Have you seen Johnson yet?
http://github.com/jbarnette/johnson/tree/master

It's goal is to wrap Mozilla's JS engine written in C, SpiderMonkey, in ruby. With this equivalent solution in place like Java's Rhino it will be possible to create an HtmlUnit like testing framwork entirely in Ruby and perhaps just extend webrat to get JS functionality. I have not yet realll played around with it and I haven't been able to find any posts about how to use it.. but it is something to keep your eye on.

Johnson seems young so, as I said earlier, we will probably try to use the more mature HtmlUnit (a'la JRuby) to do our in-memory JS testing.

-Ben



_______________________________________________
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users

Reply via email to