-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implemented junit integration features and fixed bugs
- Loading branch information
Showing
13 changed files
with
619 additions
and
222 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Eclipse templates | ||
|
||
Creates new class annotated with `@RunWith(QuackeryRunner.class)`. Defines single method annotated with `@Quackery` returning empty suite. | ||
|
||
``` | ||
@${rw:newType(org.junit.runner.RunWith)}(${qr:newType(org.quackery.junit.QuackeryRunner)}.class) | ||
public class ${primary_type_name} { | ||
@${q:newType(org.quackery.Quackery)} | ||
public static ${test:newType(org.quackery.Test)} test() { | ||
return ${staticImport:importStatic(org.quackery.Suite.suite)}suite(${primary_type_name}.class.getName())${cursor}; | ||
} | ||
} | ||
``` |
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 |
---|---|---|
@@ -0,0 +1,90 @@ | ||
package org.quackery.junit; | ||
|
||
import static org.quackery.Suite.suite; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import org.quackery.Case; | ||
import org.quackery.Suite; | ||
import org.quackery.Test; | ||
import org.quackery.run.Visitor; | ||
|
||
public class FixBugs { | ||
public static Test fixBugs(Test test) { | ||
return fixNewlineBug(fixEmptySuiteBug(fixEmptyNameBug(test))); | ||
} | ||
|
||
public static List<Test> fixBugs(List<Test> tests) { | ||
List<Test> fixed = new ArrayList<>(); | ||
for (Test test : tests) { | ||
fixed.add(fixBugs(test)); | ||
} | ||
return fixed; | ||
} | ||
|
||
private static Test fixNewlineBug(Test test) { | ||
return new Visitor() { | ||
protected Test visit(Suite visiting) { | ||
Suite suite = (Suite) super.visit(visiting); | ||
return suite(fixNewlineBug(suite.name)) | ||
.addAll(suite.tests); | ||
} | ||
|
||
protected Test visit(final Case visiting) { | ||
return new Case(fixNewlineBug(visiting.name)) { | ||
public void run() throws Throwable { | ||
visiting.run(); | ||
} | ||
}; | ||
} | ||
}.visit(test); | ||
} | ||
|
||
private static String fixNewlineBug(String name) { | ||
return name | ||
.replace('\n', ' ') | ||
.replace('\r', ' '); | ||
} | ||
|
||
private static Test fixEmptySuiteBug(Test test) { | ||
return new Visitor() { | ||
protected Test visit(Suite visiting) { | ||
Suite suite = (Suite) super.visit(visiting); | ||
return suite.tests.isEmpty() | ||
? successfulCase(suite.name) | ||
: suite; | ||
} | ||
}.visit(test); | ||
} | ||
|
||
private static Case successfulCase(String name) { | ||
return new Case(name) { | ||
public void run() {} | ||
}; | ||
} | ||
|
||
private static Test fixEmptyNameBug(Test test) { | ||
return new Visitor() { | ||
protected Test visit(Suite visiting) { | ||
Suite suite = (Suite) super.visit(visiting); | ||
return suite(fixEmptyNameBug(suite.name)) | ||
.addAll(suite.tests); | ||
} | ||
|
||
protected Test visit(final Case visiting) { | ||
return new Case(fixEmptyNameBug(visiting.name)) { | ||
public void run() throws Throwable { | ||
visiting.run(); | ||
} | ||
}; | ||
} | ||
}.visit(test); | ||
} | ||
|
||
private static String fixEmptyNameBug(String name) { | ||
return name.isEmpty() | ||
? "[empty_name]" | ||
: name; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.