I've declared an expected exception with Kotlin:
@Rule
public var exception = ExpectedException.none()
Now my integration test case:
@Test
@Transactional
fun authorize_withInvalidToken()
{
val response = controller.authorize(networkType = "facebook", oauthToken = "", oauthTokenSecret = null)
exception.expect(UnauthorizedException::class.java)
}
I get the error:
org.junit.internal.runners.rules.ValidationError: The @Rule 'exception' must be public.
Is there a way to fix this? For now I'll just use manual try/catch/assert
Annotate the exception property with @JvmField
:
@Rule
@JvmField
var exception = ExpectedException.none()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With