如何参数化 Spring Boot 测试的属性值

aks*_*618 5 java testing parameterized-tests spring-boot spring-boot-test

我正在使用 spring boot 开发一个聚合框架,该框架可用于聚合多种 I/O 操作的结果。此外,它还支持非阻塞(反应式)和阻塞聚合层,该聚合层由属性控制,该属性又用于条件 bean。对于集成测试,我一直在使用此设置:

abstract class HttpUpstreamTests {
    // Setup & test logic
}

@SpringBootTest(properties = {
        "aggregation.reactive.enabled=false",
})
class BlockingAggregationIT extends HttpUpstreamTests {}

@SpringBootTest(properties = {
        "aggregation.reactive.enabled=true",
})
class NonBlockingAggregationIT extends HttpUpstreamTests {}
Run Code Online (Sandbox Code Playgroud)

现在我必须添加几个基类:

abstract class MongodbUpstreamTests {
    // Setup & test logic
}
abstract class SqlUpstreamTests {
    // Setup & test logic
}
Run Code Online (Sandbox Code Playgroud)

但当然,我不能让 IT 类从多个抽象类扩展。一种方法是使所有 upstrteam 测试参数化测试,但我似乎找不到一种方法来使用该方法与@SpringBootTest(properties="aggregation.reactive.enabled=false"). 有没有办法使用不同的属性作为参数化测试的参数?