Skip to content
0:00 / 0:00

#mocking#python#functionalcoreimperativeshell

Talk: Harry Percival - Stop Using Mocks (for a while)

PyCon US

34K subscribers • 26 videos on Hallway • Conference channel

YouTube
  • One of the most-watched uploads on PyCon US, a conference or university channel Hallway lists. Nobody has recommended it in the communities yet, so it ranks below community picks.
  • Presented by Harry Percival
  • An opinion. It argues one side of a question engineers disagree on.

Intermediate. Assumes working knowledge.

15K views6 years ago

Software designTools and practiceTestingDesign patternsSoftware architecture

Harry Percival argues that avoiding mocks forces better code design and explains how to separate business logic from I/O concerns.

Presented by: Harry Percival Classic testing tutorials usually present code that’s free of side-effects and external I/O dependencies, but the real world is seldom so straightforward. We find ourselves reaching for mocks to keep our tests isolated, and that often leads to tests that are hard to understand and maintain, and we start to question their value. When we substitute integration or end-to-end tests to assure ourselves that things work in the real world, we end up with test suites getting slower and slower, and instead of a “test pyramid” we end up with an “ice cream cone”. This talk proposes a cure: if we stop ourselves from using mocks, cold turkey, we will be forced to think more carefully about how to design our code, how to separate business logic from integration and I/O concerns. The talk will cover patterns like “Functional Core, Imperative Shell”, the use of Dependency Injection and hand-rolled fakes as an alternative to mocking and patching, and show how they can help us get better-designed code, more maintainable tests, and a healthy test pyramid.

Why it's here

A top upload from a listed channel

PyCon US is on Hallway's list of conference and university channels, and this upload is one of its most-watched talks or lectures. Nobody has recommended it in the communities yet, so it ranks below community picks.