-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from giograno/master
Detection thresholds and numerical detection
- Loading branch information
Showing
42 changed files
with
2,944 additions
and
668 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,47 @@ | ||
package testsmell; | ||
|
||
import com.github.javaparser.ast.CompilationUnit; | ||
import thresholds.Thresholds; | ||
|
||
import java.io.FileNotFoundException; | ||
import java.util.List; | ||
import java.util.HashSet; | ||
import java.util.Set; | ||
|
||
public abstract class AbstractSmell { | ||
protected Thresholds thresholds; | ||
protected Set<SmellyElement> smellyElementsSet; | ||
|
||
public AbstractSmell(Thresholds thresholds) { | ||
this.thresholds = thresholds; | ||
this.smellyElementsSet = new HashSet<>(); | ||
} | ||
|
||
public abstract String getSmellName(); | ||
|
||
public abstract boolean getHasSmell(); | ||
/** | ||
* Return 1 if any of the elements has a smell; 0 otherwise | ||
*/ | ||
public boolean hasSmell() { | ||
return smellyElementsSet.stream().filter(SmellyElement::isSmelly).count() >= 1; | ||
} | ||
|
||
public abstract void runAnalysis(CompilationUnit testFileCompilationUnit, | ||
CompilationUnit productionFileCompilationUnit, | ||
String testFileName, | ||
String productionFileName) throws FileNotFoundException; | ||
|
||
public abstract void runAnalysis(CompilationUnit testFileCompilationUnit,CompilationUnit productionFileCompilationUnit, String testFileName, String productionFileName) throws FileNotFoundException; | ||
/** | ||
* Returns the set of analyzed elements (i.e. test methods) | ||
*/ | ||
public Set<SmellyElement> getSmellyElements() { | ||
return smellyElementsSet; | ||
} | ||
|
||
public abstract List<SmellyElement> getSmellyElements(); | ||
/** | ||
* Returns the number of test cases in a test suite (jUnit test file). | ||
* In theory, it counts all the smelly elements (i.e., the methods), that are smelly | ||
*/ | ||
public int getNumberOfSmellyTests() { | ||
return (int) smellyElementsSet.stream().filter(SmellyElement::isSmelly).count(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package testsmell; | ||
|
||
/** | ||
* There are the thresholds for the test smells detection proposed by Spadini et.al. in | ||
* the paper _Investigating severity thresholds for test smells_. | ||
*/ | ||
public class DetectionThresholds { | ||
|
||
public static int EAGER_TEST = 4; | ||
public static int ASSERTION_ROULETTE = 3; | ||
public static int VERBOSE_TEST = 13; | ||
public static int CONDITIONAL_TEST_LOGIC = 0; | ||
public static int MAGIC_NUMBER_TEST = 0; | ||
public static int GENERAL_FIXTURE = 0; | ||
public static int MYSTERY_GUEST = 0; | ||
public static int RESOURCE_OPTIMISM = 0; | ||
public static int SLEEPY_TEST = 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.