Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the best strategy for adding tests to an existing rails project?

There is an existing project that is already deployed in production. We want to add some tests on it (the sooner the better) and I have to choose between going the BDD way (rspec/cucumber) or the TDD way (TestUnit). I am really starting with BDD and I am wondering what could be the best decision to take? I am affraid that using rspec/cucumber on an existing rails project (which was deployed this week and requires really fast iterations) will be quite hard to do (especially that it is not supposed to be used this way, I mean we are supposed to write stories/features first and iterate from there).

TestUnit could be more reasonable, may be.

Do you have any thoughts on that? An experience to share? Some advices?

like image 551
Amokrane Chentir Avatar asked Nov 15 '22 00:11

Amokrane Chentir


1 Answers

I believe the easiest way to get coverage for an existing application is to use cucumber. This will allow to describe and document how to the website/application should work (and will keep working).

Because it works from the outside in, this also has the advantage you do not need to comprehend the inner workings completely yet. At the same time, you test all layers of the application (model-view-controller) in one test.

When you start actually changing code, then I would start adding the unit-tests for the code you are changing, using your favourite testing framework. I personally favour rspec, but as you know this is a personal choice :)

like image 54
nathanvda Avatar answered Nov 24 '22 00:11

nathanvda