Upgrade to Pro — share decks privately, control downloads, hide ads and more …

So writing tests feels painful. What now?

So writing tests feels painful. What now?

When you write tests, you are interacting with your code. Like any user experience, you may encounter friction. Stubbing endless methods to get to green. Fixing unrelated spec files after a minor change. Rather than push on, let this tedium guide you toward better software design.

With examples in RSpec, this talk will take you step-by-step from a troublesome test to an informed refactor. Join me in learning how to attune to the right signals and manage complexity familiar to any Rails developer. You’ll leave with newfound inspiration to write clear, maintainable tests in peace. Your future self will thank you!

Stephanie Minn

May 06, 2024
Tweet

More Decks by Stephanie Minn

Other Decks in Programming

Transcript

  1. What have we done so far? Made explicit the data

    required for the method under test
  2. What have we done so far? Made explicit the data

    required for the method under test Unearthed coupling to Stripe via subscription
  3. What have we done so far? Made explicit the data

    required for the method under test Unearthed coupling to Stripe via subscription Learned how trials are started
  4. Responsiblities of #upgrade 1. Starts a trial 2. Determines if

    membership has a subscription 3. Constructs subscription 4. Updates subscription 5. Sends notification 6. Updates membership
  5. “The biggest obstacle to improvement in large code bases is

    the existing code. But I’m not talking about how hard it is to work in difficult code; I’m talking about what that code leads you to believe.” — Michael Feathers, Working Effectively with Legacy Code
  6. Books • Ruby Science - thoughtbot • Practical Object-Oriented Design

    - Sandi Metz • Sustainable Rails - David Bryant Copeland • Rails Test Prescriptions - Noel Rappin • Growing Object-Oriented Software Guided by Tests - Steve Freeman & Nat Pryce Talks • Therapeutic Refactoring - Katrina Owen • Refactoring from Good to Great - Ben Orenstein
  7. “Pretending that something doesn’t exist if it’s hard to quantify

    leads to faulty models. Human beings have been endowed not only with the ability to count, but also with the ability to assess quality.” — Donella Meadows, Thinking in Systems