Talks
Speakers
Events
Topics
Sign in
Home
Talks
Speakers
Events
Topics
Leaderboard
Use
Analytics
Sign in
Suggest modification to this talk
Title
Description
Tests are supposed to save us money. How is it, then, that many times they become millstones around our necks, gradually morphing into fragile, breakable things that raise the cost of change? We write too many tests and we test the wrong kinds of things. This talk strips away the veil and offers simple, practical guidelines for choosing what to test and how to test it. Finding the right testing balance isn't magic, it's a magic trick; come and learn the secret of writing stable tests that protect your application at the lowest possible cost.
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
### Summary of "Magic Tricks of Testing" In the talk "Magic Tricks of Testing" by Sandi Metz at the Ancient City Ruby 2013 event, the speaker addresses the common frustrations developers face with testing, particularly the pitfalls of having too many fragile and slow tests that can hinder productivity. The talk aims to demystify effective testing practices by introducing practical guiding principles to achieve cost-effective, stable tests. #### Key Points: - **Frustration with Testing:** Many developers in the community express their discontent with tests due to their slowness and fragility, which can disrupt workflows and ultimately lead to a diminished value in testing. - **The Illusion of Testing Value:** Despite the widespread advocacy for testing, Metz points out that the reality for many is that the promise of testing has not been fulfilled, leading to a questioning of their worth. - **Strategies for Effective Unit Testing:** Metz emphasizes the importance of unit tests over integration tests, outlining the need for tests that are: - Thorough - Stable - Fast - Few in number - **Focusing on Messages:** The speaker introduces the idea of treating objects as black boxes that communicate via messages, stressing the importance of understanding these messages to create better tests. - **Testing Incoming Query and Command Messages:** - Incoming query messages should be tested by making assertions about what they send back, focusing on the public interface rather than internal implementation. - Incoming command messages are to be tested by asserting direct public side effects. - **Avoiding Over-Specification:** Metz warns against testing private methods or making assertions on them, as this can lead to unnecessary complexity and brittle tests. - **Outgoing Messages:** - Outgoing query messages should not be tested, similar to private methods, as they do not have visible side effects. - Outgoing command messages should be tested by ensuring that they are sent, while being cautious of distant side effects that can lead to integration tests rather than unit tests. - **Use of Mocks and Stubs:** The final portion of the talk warns about the fragility of mocks and stubs. Instead, Metz highlights the importance of keeping tests simple and ensuring they provide clear proofs of correctness without unnecessary dependencies. #### Conclusions and Takeaways: - Testing should enhance productivity without becoming a burden. By focusing on simplicity, careful selection of what to test, and understanding message interactions within the application, developers can maintain effective testing practices. - The ultimate goal is to reach a point where developers can say, "I love my tests," thereby reinforcing their value and utility in software development.
Suggest modifications
Cancel