【发布时间】:2018-05-23 14:46:50
【问题描述】:
我使用 junit 5 的下一个版本
<junit.jupiter.version>5.2.0</junit.jupiter.version>
<junit.platform.version>1.2.0</junit.platform.version>
<junit.vintage.version>5.2.0</junit.vintage.version>
Kotlin 版本是
<kotlin.version>1.2.31</kotlin.version>
我尝试将 junit 5 中的新断言功能与 kotlin 类似
assertAll("person",
{ assertEquals("John", person.firstName) },
{ assertEquals("Doe", person.lastName) }
)
但是代码分析器说没有找到合适的方法版本。
Error:(28, 9) Kotlin: None of the following functions can be called with the arguments supplied:
public fun assertAll(vararg executables: () -> Unit): Unit defined in org.junit.jupiter.api
public fun assertAll(heading: String?, vararg executables: () -> Unit): Unit defined in org.junit.jupiter.api
如果我这样编写代码,它可以正常工作。有什么诀窍?
assertAll("person",
Executable { assertEquals("John", person.firstName) },
Executable { assertEquals("Doe", person.lastName) }
)
【问题讨论】: