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

Obeying the Testing Goat: building a test obses...

Obeying the Testing Goat: building a test obsessed culture at your company

We all know we should test our code. We all know that we should have a hypothetically perfectly tested codebase. But how many people actually do? Why don't we? What's stopping us? We'll talk about the skills and mentality everyone needs to have, the infrastructure that cuts down on the amount of work that you need to do to write a test, directly influencing how many of your coworkers actually write comprehensive tests. We'll also talk about planning and the torturous process of accepting what you can't test. You'll leave this talk planning to add an onboarding session dedicated to testing, excited about test infrastructure such as factories, and looking forward to the day that you discover the tests are there, and they can help you understand the code's structure and intended usage.

Avatar for Julia Duimovich

Julia Duimovich

November 18, 2017

Other Decks in Technology

Transcript

  1. @jduims IT ME • I’m early career • Mostly have

    done backend web development • Also new at my job
  2. @jduims ENGINEERING PROBLEM • Regressions & breakages are a real

    risk • Lack of testing infrastructure makes writing tests much more work • Testing is a skill that not everyone knows how to do
  3. @jduims SAD REALITIES • You can’t & shouldn’t just give

    up & write all of the tests by yourself • Tests are great but don’t add “visible business value” • Strong-arming coworkers has limited value • Tests are useless unless you run them [CI ]
  4. @jduims WHAT’S A GOOD TEST/SUITE? • Tells you code meets

    the requirements • “actually test things” • FREE DOCUMENTATION OF INTENDED USAGE • Have instructions on how to set them up
  5. @jduims GOOD TESTS AND SUITES… • Have docs about how

    to set up and run them • Limit mocks as much as possible • Organized so you can find things • Use planned infrastructure and tools so things are tested consistently across the code base
  6. @jduims WHY PEOPLE DON’T WRITE TESTS • No consequences •

    Nobody’s watching/no social pressure • They don’t find it fun • Don’t necessarily have the skills
  7. @jduims WHY PEOPLE DON’T WRITE TESTS • Current tests don’t

    pass (so why bother?) • Lack of testing infrastructure support (no standard provided mocks, testing tools set up, no access to a DB during the
  8. @jduims TESTING CAN HELP YOU IMPROVE… • Reliability/correctness • Certainty

    about code interactions before deploying • Clarity: writing tests lets you be the first user of your code • Prevent feature loss
  9. @jduims SET SOME WELL DEFINED GOALS • Avoid infinite yak

    shaving • My current scope: • Anti-regression: Write a test that verifies every bug fix • New code means writing new tests • Plan some projects to get some standard testing infrastructure developed
  10. @jduims OTHER OPTIONS • Feature parity loss prevention: Add test

    coverage to a legacy project so you can start to change it • Leveling up test skills
  11. @jduims CO-CONSPIRATORS • Lend credibility you might not have •

    Act as additional reinforcement for you when you’re not around
  12. @jduims INFORMATION IS POWER • Review past outages- be able

    to mention ones where testing would have helped • Are you planning any big upgrades? (eg: upgrading Django) • Heat map of what code coverage you have • Have some good examples of tests that you like
  13. @jduims BOSS CHAT • Talk about what you want (based

    on your specific scope) • Frame your goals in alignment with things your boss cares about
  14. @jduims WHAT YOU REALLY WANT • PERMISSION TO: • Give

    a talk with your coworkers about new shared expectations • Add a testing chat to your on boarding • Performance management for devs who consistently don’t test • Approval to spend the time you need working on the projects from your goal
  15. @jduims COWORKER CHAT • This shouldn’t actually be about “how

    to write tests” • Just set expectations for what you want going forward • Also give heads up about what any upcoming projects coming out of that
  16. @jduims OTHER BONUS STUFF TO MENTION • Writing tests helps

    you clarify what decisions your team needs to make about implementation details • Free usage docs!!
  17. @jduims NEW EXPECTATIONS • Mention your team’s specific goal •

    Talk about code review expectations • Quality & sufficient number of tests count in the review now! • Fix a bug or issue? Write tests to verify and prevent this issue from ever happening again
  18. @jduims KEEP DOING THE WORK • Continuing education-share examples of

    good tests when you see them • Code review checklist • Regularly review metrics (code coverage heat map? Number of outages/ month) • If there are folks who aren’t on board, consequences & performance management must occur
  19. @jduims PLANNING FUTURE CODE • Think about testing while you

    decide on an architecture–Need to test with Celery if you’re using it- eager mode not a good test. • Docker-type stuff hugely helps (infrastructure in a box) • Think about skills your team has or doesn’t have before you commit to a distributed systems architecture (or other kind of new testing styles) • Give your team time to write supporting infrastructure as part of a new project
  20. @jduims ONBOARDING MEETING • Part of maintenance because you want

    to continue pushing your culture in the right direction • Help them set up their machines so they can run the test • Go through the code review checklist • Give them several “good test” examples from your code base • Consider pairing with them on a test
  21. @jduims ACCEPTANCE • You don’t control every input to your

    code • Scaling, load, concurrency are all not testable • PROD and DEV are never exactly the same • Never enough time
  22. @jduims DON’T FORGET • Prevent regression! Write tests when you

    fix bugs! • Tests are free documentation