I've got a few apps that I'd like to go back and retroactively build a test suite (RSpec & Cucumber) for, but it's a little daunting to get that process started.
What would your process be for going back on an existing app and building out a test suite for it?
Integration. Don't try to test all the combinations in integration tests. That's what unit tests are for. Just test happy-paths or most common cases.
What is Minitest? Minitest is a testing tool for Ruby that provides a complete suite of testing facilities. It also supports behaviour-driven development, mocking and benchmarking. With the release of Ruby 1.9, it was added to Ruby's standard library, which increased its popularity.
Don't use should Do not use should when describing your tests. Use the third person in the present tense. Even better start using the new expectation syntax. See the should_not gem for a way to enforce this in RSpec and the should_clean gem for a way to clean up existing RSpec examples that begin with 'should.
I would go and add highlevel tests (cucumber) first. This will give you the confidence that the behavior won't change unnoticed. I wouldn't go and add rspec tests (or maybe just a few imporant ones) because you'll probably want to refactor a lot too.
Then, run metrics. MetricFu recently got a metric called "HotSpots", that will combine other metrics and point you to the biggest troublespots in the code. These places are usually also the most critical to your application. Fix them just enough so there readable and you get a good sense of what it's about. Don't go overboard just yet.
Then, for every new feature that you'll add, add specs and clean up some code that you're interacting with. So test and refactor the dependencies of new features, but don't go beyond that. Do it in tiny chunks or you'll lose hope quickly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With