Testing in Isolation with Unit Tests
In addition to allowing greater flexibility in simulating edge cases, unit tests have two other advantages: they run very quickly, since they don’t require any setup outside of Ruby (such as files, databases, and so on), and they force us to organize our code into small, testable units. Faster tests are good, since we can more quickly see the health of our app and more quickly and frequently run tests when writing new features and fixing bugs. Having small testable units is good, too, because it means our app will be easier to understand and maintain; instead of a big long block of code, we’ll have small units that do simple things, all glued together to form the app.
To run unit tests, we’ll need to break ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access