【发布时间】:2020-05-08 17:26:55
【问题描述】:
我目前使用 junit5、wiremock 和 reassured 进行集成测试。空手道看起来很有前途,但我在数据驱动测试的设置方面有点挣扎,因为我需要准备一个嵌套数据结构,在当前设置中,它看起来如下所示:
abstract class StationRequests(val stations: Collection<String>): ArgumentsProvider {
override fun provideArguments(context: ExtensionContext): java.util.stream.Stream<out Arguments>{
val now = LocalDateTime.now()
val samples = mutableListOf<Arguments>()
stations.forEach { station ->
Subscription.values().forEach { subscription ->
listOf(
*Device.values(),
null
).forEach { device ->
Stream.Protocol.values().forEach { protocol ->
listOf(
null,
now.minusMinutes(5),
now.minusHours(2),
now.minusDays(1)
).forEach { startTime ->
samples.add(
Arguments.of(
subscription, device, station, protocol, startTime
)
)
}
}
}
}
}
return java.util.stream.Stream.of(*samples.toTypedArray())
}
}
有没有什么首选的方法可以用空手道设置这种嵌套的数据结构?我最初考虑定义 5 个不同的数组,其中包含订阅、设备、站点、协议和 startTime 的样本值,并将它们组合并合并到一个数组中,该数组将在Examples: 部分中使用。
到目前为止我还没有成功,我想知道是否有更好的方法来准备这种嵌套的数据驱动测试?
【问题讨论】:
标签: testing integration-testing karate junit5