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/
Running the jar with --help will print its usage.
- The files to analyse are given either as a CSV input file with
-f, or as a project directory with-p:- Each row of the CSV input file is
app,testFilePath,productionFilePath. The production file path is optional. - With
-p, the tool scans everysrc/test/javaandsrc/androidTest/javafolder under the directory (single- and multi-module Maven or Gradle projects). Test classes namedFooTest,FooTests,FooTestCase,FooITorTestFooare analysed, each paired withFoo.javain the same package under the module'ssrc/main/javawhen it exists. Build output folders such asbuildandtargetare skipped.
- Each row of the CSV input file is
- A detection threshold can also be specified. Possible values are
defaultandspadini. The flag is-t. By default, the tool uses the thresholds that have been originally implemented; withspadini, sensibility thresholds published by Spadini et.al. will be used. - One can specify the granularity of the detection.
booleanwill return either true or false, respectively if a given smell is present or not in the test;numericalwill return instead the number of smelly instances detected.
java -jar TestSmellDetector.jar -p path/to/project -o results.csv
Options:
-f, --file PATH The csv input file
-p, --project DIRECTORY A project directory to scan for test files,
instead of a csv input file
-t, --thresholds [default|spadini]
The threshold to use for the detection
-g, --granularity [boolean|numerical]
Boolean value of numerical for the
detection
-o, --output TEXT
-h, --help Show this message and exit