Exemple #1
0
 private JavaUnit initTestUnit(String cls) {
   JavaUnit unit = new JavaUnit(cls + "Test"); // 生成测试类
   unit.addImportStatic("org.junit.Assert.*");
   unit.addImport("org.junit.Before");
   unit.addImport("org.junit.Test");
   JavaMethod m = new JavaMethod("setUp");
   m.setAnnotation("@Before");
   unit.addMethod(m);
   return unit;
 }
Exemple #2
0
 private void addTestMethod(JavaUnit unit, String name) {
   JavaMethod m = new JavaMethod("test" + StringUtils.capitalize(name));
   m.setAnnotation("@Test");
   m.addContent("fail(\"Not yet implemented\");");
   unit.addMethod(m);
 }