Unit test code, just like any other source code, is subject to bad programming practices, known also as anti-patterns, defects and smells. Smells, being symptoms of bad design or implementation decisions, has been proven to be responsible for decreasing the quality of software systems from various aspects, such as making it harder to understand, more complex to maintain, more prone to errors and bugs.
Test smells are defined as bad programming practices in unit test code (such as how test cases are organized, implemented and interact with each other) that indicate potential design problems in the test source code.
The purpose of this project is twofold:
- Contribute to the list of existing test smells, by proposing new test smells that developers need to be aware of.
- Provide developers with a tool to automatically detect test smell in their unit test code.
Visit the project website: https://testsmells.github.io/
https://leanpub.com/javaparservisited
DeadFields implements a ClassVisitor, which allows the following steps:
- visit(ClassOrInterfaceDeclaration declaration) - a class is parsed, all declared methods and class fields (testFields array) are extracted
- visit(MethodDeclaration n) - for every declared method, some action is performed. In this example, every method is recursively searched to find all Nodes of NameExpr type (which in this case are the the fields used inside of that method).
To generate output files from TsDetect the user has to provide an input csv file with the following data:
- Project name
- Path to java test file
- Path to java produciton file e.g. PBR;C:\apps\pbr\src\test\RibTest.java;C:\apps\pbr\src\Rib.java
To execute detection in TsDetect jar directory: java -jar .\TestSmellDetector.jar pathToInputFile.csv