Context: The practice of writing tests before production code (Test-Driven Development, TDD for short) has become widespread
in the software community, aiming to improve code quality and reduce defects. However, inconsistent reporting on TDD’s effect provides room to explore its impact on test code.
Objectives: This pilot study investigated whether TDD can reduce the prevalence of test smells in student-written code, addressing the question of whether TDD improves test code quality.
Method: We employed a controlled intervention within an undergraduate programming context. Initially, students developed the String Calculator kata using their standard, unconstrained method, subsequently, we introduced TDD, and later students re-implemented the same kata adhering to TDD principles. Test code quality was assessed using established test smell detection tools and qualitative feedback was gathered through student interviews.
Results: Despite improvements in code quality metrics, students continued to generate "Magic Number" test smells in their test code.
Conclusion: This pilot study highlights the need for educators to emphasize comprehensive test design alongside TDD implementation, acknowledging the limitations inherent in a small-scale exploratory research setting.