Talks
Speakers
Events
Topics
Sign in
Home
Talks
Speakers
Events
Topics
Leaderboard
Use
Analytics
Sign in
Suggest modification to this talk
Title
Description
You probably already know: In a unit test, use test doubles to sub real dependencies. You probably also know: In reality, things are not so easy. What do you do if the dependencies span multiple layers? What if the dependencies are implicit? If we can't find the best level of isolation, test doubles can be unwieldy very quickly and they will make the test, as well as the future you, miserable. In this talk, we will look at symptoms that produce unreliable and unmaintainable tests, and develop a strategy that will make your test suite more resilient and actually enjoyable.
Date
Summarized using AI?
If this talk's summary was generated by AI, please check this box. A "Summarized using AI" badge will be displayed in the summary tab to indicate that the summary was generated using AI.
Show "Summarized using AI" badge on summary page
Summary
Markdown supported
In this talk titled "Fake Your Test Away: How To Abuse Your Test Doubles" presented by Jenny Shih at RubyConf 2021, the speaker explores the complexities of unit testing, particularly the pitfalls of using test doubles. She emphasizes that while test doubles serve as substitutes for actual dependencies, their misuse can lead to unreliable and unmaintainable tests. Jenny draws parallels between the evolution of civilizations as described by Douglas Adams and her personal evolution in understanding testing, highlighting three phases: survival (how to use test doubles), inquiry (why testing is essential), and sophistication (deciding when to eliminate tests). Key points discussed include: - **Definitions**: She defines critical terms such as 'testable', 'subject', and 'dependency' to establish clarity for the audience. - **Pyramid Model**: The ideal testing structure resembles a pyramid with unit tests at the base, followed by integration tests, and lastly acceptance tests at the top. However, she notes that the reality often diverges from this ideal. - **Integration Tests**: Jenny explains a flawed integration test example involving restaurant service, showcasing confusion arising from inappropriate implementations of test doubles leading to random test failures. - **Helicopter Unit Tests**: She describes these tests as overly cautious, attempting to control every detail, which leads to tests that cannot effectively catch production errors. - **Solution Strategies**: Jenny suggests strategies such as simplifying dependencies by utilizing the principle of least knowledge, separating decisions and delegations, and making dependencies explicit. - **Refactoring Tips**: Jenny provides practical advice on enhancing test reliability by better structuring production code, thereby minimizing the need for random or awkward test doubles. She concludes that if writing tests feels convoluted, it is often indicative of underlying problems in the production code itself. In conclusion, Jenny advocates for creating a resilient and enjoyable test suite by being mindful of test design and relying less on arbitrary test doubles. By addressing the structure of production code and its dependencies, developers can foster quality testing practices that contribute to overall software resilience and maintainability.
Suggest modifications
Cancel