在 Kotlin 和 JUnit 5 中重复 @ExtendWith

Repeated @ExtendWith in Kotlin & JUnit 5

我在 Kotlin 项目中使用 JUnit 5 并观察到与文档不匹配的行为。 在测试 class 上使用多个 @ExtendWith 注释时,我收到以下错误:

Repeatable annotations with non-SOURCE retention are not yet supported

Extension section of the JUnit documentation 中,这被列为有效选项。
我正在使用 Kotlin 1.3.10 和 JUnit 5.3.2

为什么我无法在测试 classes 中重复 @ExtendWith 注释?

可重复注释是not yet supported in Kotlin. You can, however, use the Extensions注释:

@Extensions(
    ExtendWith(...),
    ExtendWith(...)
)

您可以将所有 类 放在一个注释中:

@ExtendWith(
    A::class,
    B::class
)