Spring boot spring启动测试-多个测试可以有一个上下文吗?

Spring boot spring启动测试-多个测试可以有一个上下文吗?,spring-boot,integration-testing,junit-runner,Spring Boot,Integration Testing,Junit Runner,我有集成测试,我希望使用单一上下文 我知道所有测试都会初始化不同的bean,因此每次测试都会重新启动Spring。(added@DirtiesContext)但它不起作用 我的家长班- @SpringBootTest @RunWith(SpringRunner.class) @ContextConfiguration(classes = SpringApplicationContext.class, initializers = ConfigFileApplicationContextIniti

我有集成测试,我希望使用单一上下文

我知道所有测试都会初始化不同的bean,因此每次测试都会重新启动Spring。(added@DirtiesContext)但它不起作用

我的家长班-

@SpringBootTest
@RunWith(SpringRunner.class)
@ContextConfiguration(classes = SpringApplicationContext.class, initializers = ConfigFileApplicationContextInitializer.class)
@AutoConfigureDataJpa
@DirtiesContext
public abstract class AbstractSpringITest {
}
应用程序上下文-

@Configuration
@ComponentScan(basePackages = "com.datas_tech.ingo.core")
@TestPropertySource("classpath:test.properties")
public class SpringApplicationContext {
}
示例测试-

public class MailServiceITest extends AbstractSpringITest {

    @Autowired
    public MailService mailService;
    ...

public class UserServiceITest extends AbstractSpringITest {

    @Autowired
    public UserService userService;
    ...
我的控制台是这样的,当我为所有测试启动集成测试时

Running com.datas_tech.ingo.core.repository.log.LogRepositoryITest

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v1.5.3.RELEASE)

2017-07-19 17:27:58.613  INFO 4104 --- [           main] c.d.i.c.r.log.LogRepositoryITest         : Starting LogRepositoryITest on artur-pc with PID 4104 (started by artur in /home/artur/IdeaProjects/IngoX/core)
2017-07-19 17:27:58.614  INFO 4104 --- [           main] c.d.i.c.r.log.LogRepositoryITest         : No active profile set, falling back to default profiles: default
2017-07-19 17:28:00.213  INFO 4104 --- [           main] o.hibernate.jpa.internal.util.LogHelper  : HHH000204: Processing PersistenceUnitInfo [
    name: default
    ...]
2017-07-19 17:28:00.223  INFO 4104 --- [           main] org.hibernate.dialect.Dialect            : HHH000400: Using dialect: org.hibernate.dialect.Oracle10gDialect
2017-07-19 17:28:00.490  INFO 4104 --- [           main] org.dozer.DozerBeanMapper                : Initializing a new instance of dozer bean mapper.
2017-07-19 17:28:00.492  INFO 4104 --- [           main] org.dozer.DozerBeanMapper                : Initializing a new instance of dozer bean mapper.
2017-07-19 17:28:00.495  INFO 4104 --- [           main] org.dozer.DozerBeanMapper                : Initializing a new instance of dozer bean mapper.
2017-07-19 17:28:00.498  INFO 4104 --- [           main] org.dozer.DozerBeanMapper                : Initializing a new instance of dozer bean mapper.
2017-07-19 17:28:00.544  INFO 4104 --- [           main] org.dozer.DozerBeanMapper                : Initializing a new instance of dozer bean mapper.
2017-07-19 17:28:00.658  INFO 4104 --- [           main] c.d.i.c.r.log.LogRepositoryITest         : Started LogRepositoryITest in 2.221 seconds (JVM running for 13.261)
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 6.895 sec - in com.datas_tech.ingo.core.repository.log.LogRepositoryITest
Running com.datas_tech.ingo.core.repository.ldap.GroupRepositoryITest

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v1.5.3.RELEASE)

2017-07-19 17:28:05.629  INFO 4104 --- [           main] c.d.i.c.r.ldap.GroupRepositoryITest      : Starting GroupRepositoryITest on artur-pc with PID 4104 (started by artur in /home/artur/IdeaProjects/IngoX/core)
2017-07-19 17:28:05.629  INFO 4104 --- [           main] c.d.i.c.r.ldap.GroupRepositoryITest      : No active profile set, falling back to default profiles: default
2017-07-19 17:28:06.908  INFO 4104 --- [           main] o.hibernate.jpa.internal.util.LogHelper  : HHH000204: Processing PersistenceUnitInfo [
    name: default
    ...]
2017-07-19 17:28:06.918  INFO 4104 --- [           main] org.hibernate.dialect.Dialect            : HHH000400: Using dialect: org.hibernate.dialect.Oracle10gDialect
2017-07-19 17:28:07.184  INFO 4104 --- [           main] org.dozer.DozerBeanMapper                : Initializing a new instance of dozer bean mapper.
2017-07-19 17:28:07.188  INFO 4104 --- [           main] org.dozer.DozerBeanMapper                : Initializing a new instance of dozer bean mapper.
2017-07-19 17:28:07.190  INFO 4104 --- [           main] org.dozer.DozerBeanMapper                : Initializing a new instance of dozer bean mapper.
2017-07-19 17:28:07.192  INFO 4104 --- [           main] org.dozer.DozerBeanMapper                : Initializing a new instance of dozer bean mapper.
2017-07-19 17:28:07.231  INFO 4104 --- [           main] org.dozer.DozerBeanMapper                : Initializing a new instance of dozer bean mapper.
2017-07-19 17:28:07.406  INFO 4104 --- [           main] c.d.i.c.r.ldap.GroupRepositoryITest      : Started GroupRepositoryITest in 1.878 seconds (JVM running for 20.009)
Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 3.902 sec - in com.datas_tech.ingo.core.repository.ldap.GroupRepositoryITest
Running com.datas_tech.ingo.core.repository.ldap.UserRepositoryITest
所有测试如何使用单一上下文

怎么了

谢谢