Opening a new area of research: The intersection between TDD and test smells, where are we and where are we going to?
Recently, the paper titled “Exploring the Connection between the TDD Practice and Test Smells — A Systematic Literature Review” was published, marking the initial step towards a research area that amalgamates TDD practice and test smells. However, it was the second step, as a research draft was published in 2023. But before delving into the subject, let’s provide some context.
TDD has been a focal point in software development that has captured my attention since I first encountered the practice. I articulated my thoughts on this in detail in a blog post last year. At that time, TDD was already a widely discussed topic in both academia and among practitioners.
What I found intriguing on this journey is that irrespective of whether codebases adhere to TDD principles or not, those with unit tests tend to exhibit test smells, also known as anti-patterns. This led to an exploration of how practitioners develop software and whether they are cognizant of these test smells/anti-patterns.
This brings us back to the exploration of the intersection between the practice and the outcomes it yields. Without delving too deeply into specifics, the paper also explores other aspects of TDD over the last 13 years, such as its productivity, quality, practice, and adoption.
Correlation between studies’ focus areas and publishers by https://www.mdpi.com/2073-431X/1
In short, the data gathered on TDD focuses on four main areas: TDD adoption, Quality/Productivity, Quality, and Practice. Note that the categorization does not mention test smells or anti-patterns. This outlines the rationale behind researching test smells and TDD practice.
Research has demonstrated that test smells, based on code analysis, are detrimental to test code comprehension, while TDD is valued by practitioners for its rapid feedback. However, these areas of knowledge are often treated as “isolated entities”.
The gap between TDD practice and Test smells/anti-patterns
Certainly, the gap depicted is not absolute; there exists a gray area in between. On the left side, there is a connection with the organizational context and team settings, while on the right, it represents the outcome of the written test code. It is challenging to pinpoint whether it was developed with or without TDD. Is it possible to infer from the source code if it used TDD or not?
The intriguing aspect is that these two sides often act as opposing forces, yet they might indirectly influence one another. In that sense, the depicted outcomes have established the research area with empirical evidence, and the efforts put into it have drawn attention to further investigate how teams are practicing TDD.
The intersection between TDD practice and Test smells/anti-patterns
Currently, the focus is on building a framework that will enable teams to analyze the impact of TDD practice and test smells on the codebase. The emphasis lies on the context in which TDD is practiced. The challenge lies in finding the balance between the type of metrics and the data sources.
Researchers have diligently worked on providing various tools to identify test smells and suggest fixes on the fly, primarily for the Java ecosystem. However, there is still room to adapt these tools to different programming languages.
One of the biggest challenges in this approach is encompassing all the necessary areas of knowledge, including team settings, organizational settings, and technical practices.
While some researchers find TDD practice inconclusive, there is empirical evidence that TDD is a valued practice used daily by practitioners in software development. It might be the case that as a community, we have not yet found a platform that enables us to write code and measure its outcomes beyond test coverage.