I tried to use a unit test rule annotation and Android Studio didn't highlight any error here:
@Rule val htmlManager = HtmlManager()
However after executing the test following error happens:
org.junit.internal.runners.rules.ValidationError: The @Rule 'htmlManager' must be public.
How to fix this?
The solution is to apply @Rule annotation to property getter:
@get:Rule
val htmlManager = HtmlManager()
more detail here: https://kotlinlang.org/docs/reference/annotations.html#java-annotations
see the fixed test case code here in my open-source project: https://github.com/appham/Sharemarks/commit/310c115d5a820be900abc321cc061aeab7af2e5a#diff-5e1e851ef5b9bb333abb96dec3199a94
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