Ruby on Rails Test Coverage

Rafael A. George Duval
1 min readNov 2, 2022

--

Test coverage determines whether a piece of code has been executed. Test coverage doesn’t measure impact or quality. It just measures executed lines of code. It doesn’t expose the importance of the code.

Code-to-test ratios above 1:2 is a smell, and above 1:3 is a stink.[¹]

Focus on risky code rather than test coverage. Do not test implementation details about any framework.

Redundant coverage can kill a team’s morale. It’s the sort of thing that doesn’t bite you on day one because everything’s fast, and it’s easy to run.

Reducing redundant coverage is more a social problem than a technical one. The team needs to Identify a testing strategy covering the application's essential components.

Don’t test standard Active Record associations, validations, or scopes.[¹]

In a Ruby on Rails application, there’s little value in testing things like associations, validations, or scopes. The framework already has a vast test suite asserting that all these features work as they are supposed, so developers don’t have to redundatly test the same thing.

[¹]: David Heinemeier Hansson (2012): Testing like the TSA(https://signalvnoise.com/posts/3159-testing-like-the-tsa)

--

--

Rafael A. George Duval
Rafael A. George Duval

Written by Rafael A. George Duval

✍🏼 Building a Solo Digital Media Company 🧪 Snippets of Text [https://snippetsoftext.substack.com/subscribe]

No responses yet