This repository contains supplemental resources and materials that coincide with the "Fake It Til' You Make It: Mocking Reality So Your Tests Can Run" talk at Posit::conf(2026).
As data scientists mature in their work, many move from analysis scripts to larger codebases and packages, bringing unit testing into the workflow. For some, a handful of basic tests is enough. For others, as code grows more complex, familiar testing patterns may start to break. We’ll explore testing in isolation as a practical way to handle more challenging programming scenarios. We’ll cover the core ideas behind mocking and controlling your code’s environment while focusing on when, where, how, and why these techniques help in real projects.
"Fake it Til' You Make It" is intended for anyone already comfortable with unit testing who wants to explore strategies for isolating behavior, reducing test fragility, and expanding test coverage for complex systems.
This repository serves as a resource for relevant supplemental materials for those seeking to learn more about testing in isolation and mocking.
The slides for "Fake It Til' You Make It" can be found on this repository here.
This talk will be presented on September 16th 2026, 3:00 PM CDT in Houston, Texas United States. A recording of this talk will be available on YouTube on a later date.
Core testing
- testthat - the standard unit testing framework for R packages
- R Packages (2e), Ch. 13: Testing basics
- R Packages (2e), Ch. 14: Designing your test suite
- R Packages (2e), Ch. 15: Advanced testing techniques
Mocking & isolation
- testthat: Mocking vignette - overview of testthat's native mocking approach
- local_mocked_bindings() - testthat's built-in function for temporarily redefining function definitions in tests
- Maëlle Salmon - R-hub blog: Update on mocking for testing R packages (2024) - good current-state overview of the R mocking landscape
- httptest2: Test Helpers for ‘httr2’ - An R package that makes it easier to write tests for code and packages that wrap web APIs.
- httptest: A Test Environment for HTTP Requests in R - test helpers for isolating/mocking HTTP requests made with
httr2
Core testing
- pytest - the de facto standard test runner/framework
- unittest.mock - stdlib mocking library
- unittest.mock - getting started - practical
patch/MagicMockexamples
Mocking & isolation
- pytest-mock - thin pytest wrapper around
unittest.mock(themockerfixture) - responses - mock
requests-based HTTP calls - requests-mock - alternative HTTP mocking library for
requests - vcrpy - records real HTTP interactions once, replays them as fixtures ("cassettes") in tests
- moto - mocks AWS services for tests (handy for AWS-backed pipelines)
- Martin Fowler: Mocks Aren't Stubs- the canonical (A.K.A 'old') explainer on test doubles, and why "mock" gets overloaded
- Google Testing Blog: Know Your Test Doubles- short, concrete definitions of dummy/stub/spy/mock/fake
- Software Engineering at Google, Ch. 13: Test Doubles- deeper dive on when test doubles help vs. hurt test quality
- London vs. Chicago (mockist vs. classicist) schools of TDD- useful framing for why people disagree about how much to mock