Published Sep 3, 2019

Episode 70: Gerard Meszaros on XUnit Test Patterns

Gerard Meszaros delves into XUnit Test Patterns, focusing on creating maintainable tests, managing test fixtures, and addressing common test smells. He underscores the importance of simplicity and automated testing in agile development to ensure software testability and continuous feedback.
Episode Highlights
Software Engineering Radio - the podcast for professional software developers logo

Popular Clips

Episode Highlights

  • Testing Patterns

    In the realm of software development, testing patterns play a crucial role in maintaining efficient and reliable code. , an agile software development coach, emphasizes the importance of these patterns in creating maintainable tests. He explains that while there is no single right answer, understanding the context and trade-offs of each pattern is essential. Meszaros states, "What I try and do in each of the patterns is make the trade-off explicit."

    What are the indications for using a particular pattern? What are the counter indications?

    ---

    He highlights the need for linear test methods without conditional logic to avoid obscure tests, which can complicate the testing process 1 2.

       

    Fixture Management

    Managing test fixtures effectively is another critical aspect of unit testing. Meszaros advocates for the use of fresh fixtures over shared ones to prevent issues related to test interactions. He warns that shared fixtures can lead to complications and suggests alternatives like stubbing to mitigate setup time without compromising test integrity. Meszaros explains, "Instead of a shared fixture, use a fresh fixture."

    And unfortunately, a lot of people very quickly jump to using shared fixtures.

    ---

    He also discusses project smells, which are observable issues like bugs in production code, urging developers to trace these back to their root causes and apply appropriate patterns to resolve them 3 4.

Related Episodes