Skip to content

Commit

Permalink
fixed an issue in the detection logic
Browse files Browse the repository at this point in the history
  • Loading branch information
shehan committed Jan 29, 2018
1 parent 6f70d01 commit 1adca31
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/main/java/testsmell/smell/GeneralFixture.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@
import testsmell.Util;

import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.*;

public class GeneralFixture extends AbstractSmell {

Expand Down Expand Up @@ -101,7 +99,7 @@ private class ClassVisitor extends VoidVisitorAdapter<Void> {
private MethodDeclaration methodDeclaration = null;
private MethodDeclaration currentMethod = null;
TestMethod testMethod;
private int fixtureCount = 0;
private Set<String> fixtureCount = new HashSet();

@Override
public void visit(ClassOrInterfaceDeclaration n, Void arg) {
Expand Down Expand Up @@ -141,10 +139,10 @@ public void visit(MethodDeclaration n, Void arg) {
super.visit(n, arg);

testMethod = new TestMethod(n.getNameAsString());
testMethod.setHasSmell(fixtureCount != setupFields.size());
testMethod.setHasSmell(fixtureCount.size() != setupFields.size());
smellyElementList.add(testMethod);

fixtureCount = 0;
fixtureCount = new HashSet();;
currentMethod = null;
}
}
Expand All @@ -154,7 +152,9 @@ public void visit(NameExpr n, Void arg) {
if (currentMethod != null) {
//check if the variable contained in the current test method is also contained in the setup method
if (setupFields.contains(n.getNameAsString())) {
fixtureCount++;
if(!fixtureCount.contains(n.getNameAsString())){
fixtureCount.add(n.getNameAsString());
}
//System.out.println(currentMethod.getNameAsString() + " : " + n.getName().toString());
}
}
Expand Down

0 comments on commit 1adca31

Please sign in to comment.