java为什么集成测试的执行时间在SpringBoot2.2中显著增加?
我在那里进行了spring启动应用程序和100
集成测试。我的应用程序由以下测试依赖项组成:
- 少年4
- junit jupiter 5.3
- 嵌入式卡夫卡的弹簧卡夫卡测试
- ^用于嵌入式Redis的{a1}
- ^用于嵌入式PostgreSQL的{a2}
所有测试类都从Base
类继承:
@RunWith(JUnitPlatform.class)
@ExtendWith(SpringExtension.class)
@FlywayTest
@AutoConfigureEmbeddedDatabase
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, properties = {"spring.main.allow-bean-definition-overriding=true"})
public abstract class BaseTest {
}
例如,有这样的测试类:
public class Test1 extends BaseTest {
@Test
void test1() throws Exception {
}
}
我的应用程序使用gradle。所以,我有这样的build.gradle
:
buildscript {
ext {
springBootVersion = '2.2.0.M4'
}
repositories {
mavenCentral()
maven {
url "https://plugins.gradle.org/m2/"
}
maven {
url 'https://repo.spring.io/libs-milestone'
}
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
classpath "gradle.plugin.com.boxfuse.client:gradle-plugin-publishing:5.2.1"
}
}
我发现,集成测试的执行时间从2.2.0大幅增加。M4至2.2.0。M5。所以,我强制执行几个spring引导版本,并测量100个集成测试的执行时间。在这个测试中,我只需更改springBootVersion
值并重新加载gradle配置
- 2.2.0。M3-75秒
- 2.2.0。M4-74秒
- 2.2.0。M5-113秒
- 2.2.0。RC1-126秒
- 2.2.0。释放-120秒
- 2.2.1。释放-121秒
请注意,我的测试结果是可复制的。我的意思是,每个测试运行可能有不同的结果,但是执行时间会改变几秒钟(对于每个spring启动版本)
我不明白,发生了什么事
Upd。我创建了一个错误通知单-https://github.com/spring-projects/spring-boot/issues/18951
共 (0) 个答案