views:

35

answers:

1

Hi,

This is more of a general question and some sort of best practice discussion.

How would one test a Rails application?

There are mantras like BDD and TDD and frameworks like RSpec and Cucumber but how much is enough and what is the best way to go?

Is it enough to use Cucumber as integration tests? Are you guys writing additional unit tests, too?

So what and how is your Rails testing strategy?

Looking forward to good opinions...

+1  A: 

How would one test a Rails application? Thoroughly, aiming for Eighty percent coverage and no less!

The actual decision as to "how" is easy, but "how much" can be a difficult to answer.

I have a couple of small (almost but not quite legacy) projects with next to no tests, and the tests tend to be low-level unit tests of crucial components in the code. On occasion I wish they had more tests, but in general they are thrown together with quite small surface areas that make debugging and manual testing pretty straight forward.

In my day job, we're using rSpec, Cucumber and Selenium on a fairly large Rails project (10+ developers, several years in the making).

rSpec provides unit coverage for all our models, controllers, helpers and other classes.

Cucumber provides higher-level functional and integration tests.

Selenium is used to excercise javascript-intensive areas of our UI with javascript (running through Capybara and Cucumber). We also have a suite of regression tests in Selenium used by our Test and QA team (versions released to QA are green-lit through our CI build).

My "bare-minimum" setup these days would be unit-level coverage using rSpec on the critical and/or complex areas and a full suite of functional Cucumber tests on the critical paths through the application.

Toby Hede