Schroedinger
Schroedinger

Reputation: 1283

Getting started with Unit Testing on an existing codebase in rails?

G'day guys,

I've started a new role at a company and am working on a rails application that's used internally for particular management applications. At any rate, there are no unit tests associated with this system, and as I am building the system out I've realised there is a serious need to build unit tests so that I can have regression testing as I continue to add to this codebase.

It's a rails 1.2.7 app that I cannot migrate for reasons of compatibility, but I will be beginning to port components over it to 3.0 in the background.

There is currently only the built in tests that rails makes, and I would love some insights into how to get started with building small tests into the system and particularly at what aspects would be good to start?

This system builds a lot of individual config files, so I'm assuming a lot of the test generation would begin with testing those config files for individual aspects/elements and going from there.

I've had a look at cucumber and rspec, but just wanted to find something straightforward and easy to use that I could slowly build upon within the current system and build up a testing base over time.

Any insights, links or others would be really really appreciated.

Cheers!

Upvotes: 0

Views: 217

Answers (1)

Rishav Rastogi
Rishav Rastogi

Reputation: 15492

A lot has changed since Rails 1.2.7, definitely one of the first things would be to right unit tests, but instead of going an all out unit test attack.. Attack the problem component,

  • Write tests
  • Upgrade the component
  • Run Tests ( mostly they'll fail / possibilities of errors )
  • Make them pass
  • Refactor ( May be the new features at your disposal )

I usually do the above steps with writing the integration tests, and functional tests and unit tests for the components in the integration tests.

All the best, this ain't going to be a simple task :).

Upvotes: 1

Related Questions