Affiliation:
1. Department of Computer Science and Technology, Zhejiang University, China
2. School of Software Technology, Zhejiang University, China
3. Software Engineering Application Technology Lab, Huawei, China
Abstract
Test smell refers to poor programming and design practices in testing and widely spreads throughout software projects. Considering test smells have negative impacts on the comprehension and maintenance of test code and even make code-under-test more defect-prone, it thus has great importance in mining, detecting, and refactoring them. Since Deursen et al. introduced the definition of “test smell”, only several studies worked on discovering new test smells from test specifications and software practitioners’ experience. Indeed, many bad testing practices are “observed” by software developers during creating test scripts rather than through academic research and are widely discussed in the software engineering community (e.g., Stack Overflow). However, no prior studies explored new bad testing practices from software practitioners’ discussions, formally defined them as new test smell types, and analyzed their characteristics, which plays a bad role for developers in knowing these bad practices and avoiding using them during test code development. Therefore, we pick up those challenges and act by working on systematic methods to explore new test smell types from one of the most mainstream developers’ Q&A platforms, i.e., Stack Overflow. We further investigate the harmfulness of new test smells and analyze possible solutions for eliminating them. We find that some test smells make developers hard to fix failed test cases and trace their failing reasons. Even worse, two of them risk the correctness of test cases. Next, we develop a detector to detect test smells from software. The detector is composed of six detection methods for different smell types. These detection methods are both wrapped with a set of syntactic rules based on the code patterns extracted from different test smells and developers’ code styles. We manually construct a test smell dataset from seven popular Java projects and evaluate the effectiveness of our detector on it. The experimental results show that our detector achieves high performance in precision, recall, and F1 score. Then, we utilize our detector to detect smells from 919 real-world Java projects to explore whether the six test smells are prevalent in practice. We observe that these test smells are widely spread in 722 out of 919 java projects, which demonstrates that they are prevalent in real-world projects. Finally, to validate the usefulness of test smells in practice, we submit 56 issue reports to 53 real-world projects with different smells. Our issue reports achieve 76.4% acceptance by conducting sentiment analysis on developers’ replies. These evaluations confirm the effectiveness of our detector and the prevalence and practicality of new test smell types on real-world projects.
Publisher
Association for Computing Machinery (ACM)
Reference110 articles.
1. [n. d.]. https://github.com/kestra-io/kestra/issues/1257. [n. d.]. https://github.com/kestra-io/kestra/issues/1257.
2. [n. d.]. https://github.com/spring-projects/spring-integr ation/commit/78fa2970fa9f7b64c6bf65db886f78b5dc1e4596. [n. d.]. https://github.com/spring-projects/spring-integr ation/commit/78fa2970fa9f7b64c6bf65db886f78b5dc1e4596.
3. [n. d.]. https://github.com/Yanming-Yang/TestSmellPackage. [n. d.]. https://github.com/Yanming-Yang/TestSmellPackage.
4. [n. d.]. https://stackoverflow.com/. [n. d.]. https://stackoverflow.com/.
5. [n. d.]. https://stackoverflow.com/questions/7075938/maki ng-a-private-method-public-to-unit-test-it-good-idea. [n. d.]. https://stackoverflow.com/questions/7075938/maki ng-a-private-method-public-to-unit-test-it-good-idea.