Welcome back to another episode of the Evil Geniuses Podcast. We are coming at you with something new this week! This episode will be the first time that we are not talking about a code problem that we’ve solved because we are going to take a stand, and our stand is about testing. We are diving into the ins and outs of how you describe your test. Here at Evil Geniuses, we believe that the description of a test should describe business value not implementation.
So stay tuned as we unpack the differences between business value and implementation descriptions, the opportunities that can come from rewriting code, and why naming your tests can take quite some time to fully master. For all this and more, keep listening!
Key Points From This Episode:
Talking Points
Tests should describe the business value and not the implementation
Different types
Test that describes implementation:
“it should call the render_text method”
Test that describes business value
describing the reason to return a certain value
“it should have the amount given by the user”
“it should render text”
Who are the tests for?
Other developers reading the code
Future you if you’re refactoring
Following this practice results in better tests
Bad: “it should raise a PriceError”
Not only about raising the error; it’s about notifying the developer and user that something exceeded the max price
Supports Refactoring
clarifies the objective
Ex: feel confident to refactor as long an error is raised when the max price is exceeded
Supports Feature Changes
Feel more confident changing or removing test related to max price with description instead of just “exceeds 100”
Links Mentioned in Today’s Episode:
Evil Geniuses on Twitter
The Stand
Stride