List typeList = compilationUnit.getTypes();
for (Object type : typeList) {
TypeDeclaration typeDeclaration = (TypeDeclaration) type;
String className = typeDeclaration.getName();
getLog().info("className:" + className);
ClassTypeBuilder classTypeBuilder = new ClassTypeBuilder(className + Consts.TEST_SUFFIX);
//process methods
List<MethodDeclaration> methodDeclarations = MembersFilter.findMethodsFrom(typeDeclaration);
for (MethodDeclaration methodDeclaration : methodDeclarations) {
//has method and add import
compilationUnitBuilder.buildImports(null);
String methodName = methodDeclaration.getName();
getLog().info("methodName:" + methodDeclaration.getName());
classTypeBuilder.buildMethod(methodName + Consts.TEST_SUFFIX, methodDeclaration);
}
compilationUnitBuilder.buildClass(classTypeBuilder.build());
}
CompilationUnit testCompilationUnit = compilationUnitBuilder.build();
//写入测试代码文件