Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Options for full stack testing in Ruby on Rails

There are quite a number of options for Full-Stack testing of Rails applications. Some use real browsers, some are headless, some don't run javascript at all.

Which tools do you use or recommend and why?

List of browser simulators or automators:

  • Rails built-in support for integration and functional tests (no JS)
  • Webrat
  • Webrat::selenium
  • Selenium
  • Celerity (through Culerity)
  • Watir
  • ...

List of testing DSLs and frameworks:

  • Rails defaults (assertions, ...)
  • Shoulda
  • Cucumber
  • Capybara (unified DSL for several browser simulators)
  • ...
like image 884
Daniel Beardsley Avatar asked Oct 01 '10 19:10

Daniel Beardsley


2 Answers

All rails applications benefit from a good coverage of unit and functional tests, whether you use rspec or shoulda etc, is mostly a matter of personal preference. I'm a fan of shoulda mostly for the context blocks it provides, making setting up test scenarios much easier and clearer to understand.

I don't think browser simulators/automators are needed unless your application is quite javascript heavy. I'd recommend only using them to test javascript, and for that purpose it's definitely better to go with driving a real browser than to simulate. The app I'm working on now is quite javascript heavy and we're using cucumber along with watir/firewatir to run our cucumber tests in firefox for the javascript driven functions on our site.

like image 134
Jeremy Avatar answered Sep 22 '22 05:09

Jeremy


I have used a bunch of things during my Rails career over the last few years.

Currently working on a pretty large Rails app on JRuby with very solid test coverage and our stack looks like the following.

Unit Testing:

  • RSpec coverage of models, helpers, libraries and controllers. Controller coverage tends to be very high-level
  • JSpec coverage for a project that is using some pretty cutting edge JS and HTML 5 wizardry

Functional Testing:

  • Cucumber using Capybara and Culerity (we just converted from WebRat in order to get coverage of JS-heavy front-ends from Cucumber)
  • Selenium that is now "legacy" and slowly being migrated to cucumber/capybara
like image 44
Toby Hede Avatar answered Sep 22 '22 05:09

Toby Hede