Episode 70: Gerard Meszaros on XUnit Test Patterns

Topics covered
Popular Clips
Episode Highlights
Test Smells
Gerard Meszaros introduces the concept of test smells, drawing parallels to code smells as defined by Martin Fowler and Kent Beck. He categorizes these smells into code, behavior, and project smells, each representing different symptoms encountered during testing. Meszaros elaborates on project smells, which are often visible to project managers when bugs appear in production, indicating issues like inadequate test-driven development or lack of proper training for developers 1 2.
The test smells sort of fall into three categories. And by categories, I mean it's around how you discover the smell.
---
These categories help identify the root causes of testing issues and guide the application of appropriate patterns to resolve them 3.
Behavior Smells
Behavior smells, according to Gerard Meszaros, are particularly insidious as they manifest unpredictably during test execution. These include erratic tests that pass or fail based on circumstances like time of day or system state, often due to unrepeatable tests or resource optimism 4 5. Meszaros explains that debugging these issues can be complex, requiring troubleshooting flowcharts to identify whether tests are interacting with each other or suffering from shared resource conflicts 6.
Behavior smells really come and they just come and chase you down and get you, and they bite your leg and hang on until you do something about them.
---
Addressing these smells often involves setting up fresh fixtures for each test to ensure consistency and reliability.
Code Smells
Code smells in test code can make it difficult to read and maintain, often due to obscure logic or poor structure. Gerard Meszaros emphasizes the importance of writing maintainable tests, as they are optional and can be discarded if they become too cumbersome 7 8. He suggests using test patterns to improve test code quality, ensuring tests are robust and easy to understand.
The problem with that analogy is if I refactor my production code and the tests don't break, I was successful.
---
Testing the tests themselves is crucial, often involving fault injection to verify their effectiveness 9.
Related Episodes


Episode 167: The History of JUnit and the Future of Testing with Kent Beck
Answers 383 questions

SE-Radio Episode 256: Jay Fields on Working Effectively with Unit Tests
Answers 383 questions

Episode 2: Dependencies
Answers 383 questions

Episode 46: Refactoring Pt. 1
Answers 383 questions

Episode 155: Johannes Link & Lasse Koskela on TDD
Answers 383 questions

Episode 42: Interview Gregor Hohpe
Answers 383 questionsEpisode 1: Patterns
Answers 383 questions

SE Radio 572: Gregory Kapfhammer on Flaky Tests
Answers 383 questions

Episode 20: Interview Michael Stal
Answers 383 questions

366: Test Automation
Answers 383 questions

Episode 134: Release It with Michael Nygard
Answers 383 questions

Episode 81: Interview Erich Gamma
Answers 383 questions
Episode 54: Interview Frank Buschmann
Answers 383 questions

SE-Radio Episode 283: Alexander Tarlinder on Developer Testing
Answers 383 questions

Episode 68: Dan Grossman on Garbage Collection and Transactional Memory
Answers 383 questions













