private TypeSpec buildTypeSpec(List<MethodSpec> methodSpecs, List<FieldSpec> fieldSpecs, MethodSpec setUp) { return TypeSpec.classBuilder(this.restControllerModel.getSimpleClassName()) .addAnnotation(Transactional.class) .addAnnotation( AnnotationSpec.builder(RunWith.class) .addMember("value", "$T.class", SpringJUnit4ClassRunner.class) .build() ) .addAnnotation( AnnotationSpec.builder(ComponentScan.class) .addMember("basePackages", "{$S, $S}", "YOUR_DTOs_PACKAGE", "YOUR_SERVICEs_PACKAGE") .build() ) .addAnnotation(SpringBootTest.class) .addModifiers(Modifier.PUBLIC) .addFields(fieldSpecs) .addMethod(setUp) .addMethods(methodSpecs) .build(); }