views:

680

answers:

5

How would you make a decision between cucumber and shoulda if you were about to choose a testing framework?

What differentiates these two frameworks primarily?

+2  A: 

They have completely different objectives. Shoulda is a unit testing extension built on top of Test::Unit.

Cucumber is a Acceptance/Functional Testing framework that can use Test::Unit/RSpec/Whatever for doing the assertions.

Shoulda can be directly compared to RSpec, for instance.

Nando Vieira
A: 

Cucumber is targeting Acceptance Testing. Shoulda is a Unit Testing framework.

khelll
+1  A: 

Shoulda is an extension of the Test::Unit framework that consists of test macros, assertions, and helpers. Shoulda is a prettier way to write unit tests.

Cucumber - a rewrite of RSpec's "Story runner" - is a tool for Behaviour-Driven Development. It allows you to write executable specifications in a business-readable domain-specific language. Cucumber is more an acceptance testing tool.

Cucumber and Shoulda have thus different objective (even if Shoulda can be used for BDD).

Pascal Thivent
+2  A: 

I don't see anyone else mentioning that you actually can use Shoulda as the "test-engine" for Cucumber.

Jonas Elfström
+8  A: 

As everybody has pointed out, Cucumber and Shoulda have fairly different objectives. You can think of Cucumber as being the "view from 10,000 feet" testing framework - you define a broad feature or specific user interaction and make sure everything works together. Shoulda is for unit testing - you pick out a specific model and thoroughly test all the picky little bits of functionality for that individual piece.

Usually, you would want to use these sort of frameworks in conjunction. For example, most of your broad, high level tests can be written in Cucumber, but when there's a particularly complex or opaque bit of code in your system, you can drill down with Shoulda or RSpec to test the particulars.

John Hyland