Ruby on Rails Testing Heuristics

--

Tests aren’t free. Every line of code has a cost. It takes time to write it, it takes time to update it, and it takes time to read and understand it.

Testing what’s useful takes nuance, experience, and dozens of fine-grained heuristics. Some heuristics that help to reduce the complexity and cost of tests in Ruby on Rails applications are the following:

- Don’t aim for 100% coverage. Code-to-test ratios above 1:2 is a smell.

- Don’t test standard[ActiveRecord associations, validations, or scopes.

- Reserve integration tests for issues arising from integrating separate elements.

- Don’t test first every controller, model, and view. Focus effort on testing where risk exists.

--

--

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