Where to Start?
Explore how to start your test-driven development cycle by focusing on initializing objects and specifying their expected behavior with RSpec. Understand strategies for making tests fail deliberately, writing minimal unit tests, and following Rails conventions for organizing test files. This lesson guides you through the foundational steps to structure tests that enhance your Rails code and streamline development.
We'll cover the following...
TDD starting points
Good options for starting a TDD cycle are:
- To specify the objects’ initialization state or methods under test
- Happy path: A single representative example of the error-free version of the algorithm
Which starting point we choose depends on how complicated the feature is.
In this course, we’ll start with the initial state and will later move to the happy path. As a rule of thumb, if it takes more than a couple of steps to define an application’s instance, we’ll only start with initialization. Here’s some pointers to begin with:
-
Instead of thinking about what will make a test pass, think about making it fail. If there’s no way to make even a new test fail, ...