Java library for automatic Test Smells detection in test code.
| Test Smell | Description |
|---|---|
| Assertion Roulette | Multiple assertions without identification message |
| Conditional Test Logic | Tests with conditional logic (if/switch/loop) |
| Constructor Initialization | Initialization via constructor instead of @Before |
| Default Test | Test that only checks the default flow |
| Dependent Test | Tests that depend on other tests execution |
| Duplicate Assert | Duplicate assertions in the same test |
| Eager Test | Test that verifies multiple methods |
| Empty Test | Test with no body |
| Exception Catching Throwing | Catching and rethrowing exceptions in test |
| General Fixture | Overly generic fixture shared across tests |
| Ignored Test | Skipped/ignored test |
| Lazy Test | Test that does not verify the result |
| Magic Number Test | Usage of magic numbers in assertions |
| Mystery Guest | Test accessing external resources (files, network, database) |
| Print Statement | Usage of System.out/System.err in test |
| Redundant Assertion | Redundant assertions |
| Resource Optimism | Optimistic resource access without verification |
| Sensitive Equality | Equality comparison using toString() |
| Sleepy Test | Usage of Thread.sleep() in test |
| Unknown Test | Test that does not follow JUnit patterns |
| Verbose Test | Test with excessive lines / verbose logging |
- JUnit 3 (junit.framework)
- JUnit 4 (@Test)
- JUnit 5 (org.junit.jupiter)
java -jar jnose-core-<version>-jar-with-dependencies.jar <project-path>Available on Maven Central and GitHub Packages:
<dependency>
<groupId>io.github.arieslab</groupId>
<artifactId>jnose-core</artifactId>
<version>0.9.0</version>
</dependency>If using GitHub Packages, add the repository:
<repositories>
<repository>
<id>github</id>
<url>https://maven.pkg.github.com/arieslab/jnose-core</url>
</repository>
</repositories>Config config = new Config() {
public boolean assertionRoulette() { return true; }
public boolean conditionalTestLogic() { return true; }
// enable/disable each test smell
public int maxStatements() { return 50; }
};
JNoseCore jnose = new JNoseCore(config);
List<TestClass> results = jnose.getFilesTest("/path/to/project");
for (TestClass tc : results) {
System.out.println(tc.getName() + " - " + tc.getListTestSmell().size() + " smells");
}mvn clean packageGenerates:
target/jnose-core-<version>.jartarget/jnose-core-<version>-jar-with-dependencies.jar(with all dependencies)
Apache License 2.0