The presence of test smells related to low-quality test cases is a known factor contributing to problems in maintaining both test suites and production code. The need to avoid and fix test smells is becoming more and more popular in the scientific community, as well as the importance of knowing how to detect and refactor existing test cases. However, these practices are very little considered in academic testing courses, due also to the difficulty of making them attractive to students.

A position paper has been recently presented at Gamify ’24 (3rd ACM International Workshop on Gamification in Software Development, Verification, and Validation} in Wien. It is freely available at : https://dl.acm.org/doi/10.1145/3678869.3685687 .

It presents an approach for teaching test smells based on gamification. It exploits  a tool, TSGame, that provides a serious game where students can familiarize with test smells by practicing with their detection and removal from JUnit test code. TSGame has been implemented as a Web-based application that allows a teacher to assign students test smell detection and refactoring tasks that they have to accomplish in game sessions.

Two main features are available in TSGame: Test Smell Detection Quiz and Test Smell Refactoring.

In Test Smell Detection Quiz the student has to guess which test smells are included in a JUnit test class. In the Test Smell Refactoring with Feedback game mode, the tool shows the list of test smells found in a given test class and the student has to refactor the test code for removing test smells (without introducing new ones and without losing code coverage). This game mode may be competitive or collaborative. In this latter case, the student can share his solution to other students that can rate/ comment/ improve it.

The completion of the tasks  provide rewards (points) that unlock the most difficult tasks. A preliminary version of the tool has been validated in the context of a Software Testing course at Master degree level, with 37 students that showed the tool effectiveness and usefulness for test smell learning. Stay in touch for future releases of the tool and open calls for its experimentation!

Similar Posts