在Kotlin和JUnit 5中重复@ExtendWith

时间:2018-11-29 17:52:55

标签: junit kotlin junit5

我在Kotlin项目中使用JUnit 5,并且观察到与文档不匹配的行为。 在测试类上使用多个var user = new Parse.User(); user.set("username", "sampeusername"); user.set("password", "sample@email.com"); user.signUp({ success: function(response) { alert('Account created'); }, error: function(response, error) { alert('Error: ' + error.message); } }); 批注时,出现以下错误:

@ExtendWith enter image description here

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

为什么我不能在测试类上重复 Repeatable annotations with non-SOURCE retention are not yet supported 注释?

2 个答案:

答案 0 :(得分:1)

可重复的注释为not yet supported in Kotlin。但是,您可以使用Extensions批注:

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

答案 1 :(得分:1)

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

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