Skip to main content
The Bike Shed

438: Writing abstractions in tests

49 min episode · 2 min read

Episode

49 min

Read time

2 min

AI-Generated Summary

Key Takeaways

  • Test abstractions: Good test abstractions shouldn't require jumping to definitions - readers should understand functionality from method names like "login_as_admin" without checking implementation details.
  • Custom matchers over shared examples: Custom matchers provide better composition than shared examples, which couple behaviors like inheritance and force unwanted dependencies between test cases.
  • Helper method design: Helper methods should return values rather than set state, be called inline within test examples, and have descriptive names indicating setup conditions.
  • Abstraction frequency: Test abstractions that require frequent changes indicate poor abstraction choices - stable abstractions suggest you've correctly identified truly similar rather than coincidentally similar code.

What It Covers

Joelle and Steph explore when and how to use abstractions in test code, comparing helper methods, custom matchers, and shared examples for better test readability.

Key Questions Answered

  • Test abstractions: Good test abstractions shouldn't require jumping to definitions - readers should understand functionality from method names like "login_as_admin" without checking implementation details.
  • Custom matchers over shared examples: Custom matchers provide better composition than shared examples, which couple behaviors like inheritance and force unwanted dependencies between test cases.
  • Helper method design: Helper methods should return values rather than set state, be called inline within test examples, and have descriptive names indicating setup conditions.
  • Abstraction frequency: Test abstractions that require frequent changes indicate poor abstraction choices - stable abstractions suggest you've correctly identified truly similar rather than coincidentally similar code.

Notable Moment

Steph suggests creating a game where developers read random test examples from their codebase to practice understanding code, turning test comprehension into team learning.

Know someone who'd find this useful?

You just read a 3-minute summary of a 46-minute episode.

Get The Bike Shed summarized like this every Monday — plus up to 2 more podcasts, free.

Pick Your Podcasts — Free

Keep Reading

More from The Bike Shed

We summarize every new episode. Want them in your inbox?

Similar Episodes

Related episodes from other podcasts

This podcast is featured in Best Cybersecurity Podcasts (2026) — ranked and reviewed with AI summaries.

You're clearly into The Bike Shed.

Every Monday, we deliver AI summaries of the latest episodes from The Bike Shed and 192+ other podcasts. Free for up to 3 shows.

Start My Monday Digest

No credit card · Unsubscribe anytime