Simpleton
Simpleton

Reputation: 6415

How do I go about adding testing to a finished rails app?

Right so I started a rails app [3.0.9] a while back and didn't include any testing, and now that I'm nearing the end of it, the daunting task looms. I don't actually have testing experience yet. A cardinal sin, I know, but nothing that can be done about it now other than fix it.

Luckily in my case, it's a relatively small app with just 4 models, and only a few controller methods per model. The business logic is mostly non-trivial. Where would I start testing here? Should I do cucumber tests and add RSpec to the exceptions? What combination should give me enough coverage to confidently push it to production when the time comes?

Upvotes: 2

Views: 114

Answers (4)

nathanvda
nathanvda

Reputation: 50057

What I generally advise in a case like this (a finished site and no tests) is to write black-box tests first with cucumber. This will make sure you can have very quickly a test-suite that will cover purely the operational side: it will make sure the entire website works (and keeps working) as intended.

Only then I would start writing tests (I prefer rspec, but that is a matter of opinion), based on a need. The cucumber tests go through all layers, so everything could be covered. With rspec you can test your models, controllers and views in isolation which is really nice, but will be a lot of work to do afterwards (although for only 4 models ...).

Upvotes: 4

Jakob W
Jakob W

Reputation: 3377

Consider this an opportunity to learn a testing framework that you think you'll like and would use in future projects since the application you have written seems relatively small.

I don't know if Heckle would work or if there is something like it, but that could help you check that your tests actually are testing what you want.

Upvotes: 0

0x4a6f4672
0x4a6f4672

Reputation: 28245

Adding tests for a small app with just 4 models is not that difficult. Any test is better than nothing. RSpec or Test::Unit will do for the beginning.

Upvotes: 0

brayne
brayne

Reputation: 1403

Rspec is awesome. If you plan to do any UI testing then watir or selenium are very good open source tools. You can use rspec or test::unit for using watir or selenium.

Upvotes: 0

Related Questions