Kotlinization of Espresso test
Executed Convert Java File To Kotlin File
When I run the test I get the following exception
org.junit.internal.runners.rules.ValidationError: The @Rule 'mActivityRule' must be public.
This is because the properties declared in Kotlin have only getters and setters when viewed from the Java side, and cannot be accessed as public fields.
If you want to access the field of the class written in Kotlin from Java, add @JvmField annotation as follows
@Rule @JvmField
var mActivityRule = ActivityTestRule(HogeActivity::class.java)
Since I don't know Kotlin's language specifications, this happens, so I need to learn the basics. I hope it will be helpful for you.
https://kotlinlang.org/docs/reference/java-to-kotlin-interop.html https://proandroiddev.com/fix-kotlin-and-new-activitytestrule-the-rule-must-be-public-f0c5c583a865