Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The @ClassRule 'resources' must be static Kotlin

Tags:

junit

I am getting this error:

org.junit.internal.runners.rules.ValidationError: The @ClassRule 'resources' must be static.

When setting up my Dropwizard Kotlin application.

like image 980
Sam Berry Avatar asked Jan 23 '26 20:01

Sam Berry


1 Answers

The variable that it is complaining about must be annotated with @JvmField and inside of a companion object. So, for example:

companion object {
    @ClassRule
    @JvmField
    val resources = ...
}
like image 77
Sam Berry Avatar answered Jan 26 '26 18:01

Sam Berry



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!