Java 类org.springframework.test.context.junit4.SpringJUnit4ClassRunner 实例源码

项目:spring-web-api-test-stubber    文件:SpringBootRestControllerTesterStubGenerator.java   
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();
    }