@ClassRule“资源”必须是静态 Kotlin

Sam*_*rry 2 junit

我收到此错误:

org.junit.internal.runners.rules.ValidationError: The @ClassRule 'resources' must be static.
Run Code Online (Sandbox Code Playgroud)

设置我的 Dropwizard Kotlin 应用程序时。

Sam*_*rry 8

它所抱怨的变量必须用@JvmField伴生对象进行注释并位于其内部。因此,例如:

companion object {
    @ClassRule
    @JvmField
    val resources = ...
}
Run Code Online (Sandbox Code Playgroud)