Generated test now work with JUnit 3, too

This commit is contained in:
Andrey Breslav
2012-07-05 17:08:22 +04:00
parent 36b254dc53
commit 4683ba4dee
2 changed files with 18 additions and 1 deletions
@@ -78,7 +78,7 @@ public class TestDataSource {
}
public String getAllTestsPresentMethodName() {
return "allTestsPresentIn" + StringUtil.capitalize(rootFile.getName());
return "testAllFilesPresentIn" + StringUtil.capitalize(rootFile.getName());
}
public String getTestClassName() {
@@ -75,6 +75,7 @@ public class TestGenerator {
p.print(FileUtil.loadFile(new File("injector-generator/copyright.txt")));
p.println("package ", suiteClassPackage, ";");
p.println();
p.println("import junit.framework.TestSuite;");
p.println("import org.junit.Assert;");
p.println("import org.junit.Test;");
p.println("import org.junit.runner.RunWith;");
@@ -101,6 +102,8 @@ public class TestGenerator {
p.println();
}
generateSuiteMethod(p);
p.popIndent();
p.println("}");
@@ -110,6 +113,20 @@ public class TestGenerator {
System.out.println("Output written to file:\n" + testSourceFile.getAbsolutePath());
}
private void generateSuiteMethod(Printer p) {
p.println("public static junit.framework.Test suite() {");
p.pushIndent();
p.println("TestSuite suite = new TestSuite();");
for (TestDataSource testDataSource : testDataSources) {
p.println("suite.addTestSuite(", testDataSource.getTestClassName(), ".class);");
}
p.println("return suite;");
p.popIndent();
p.println("}");
}
private void generateSuiteAnnotations(Printer p) {
p.println("@RunWith(Suite.class)");
p.println("@Suite.SuiteClasses({");