5
Kotlin和新的ActivityTestRule:@Rule必须是公共的
我正在尝试对Kotlin中的android应用进行UI测试。由于新系统使用ActivityTestRule,所以我无法使其工作:它可以正确编译,并且在运行时得到: java.lang.Exception: The @Rule 'mActivityRule' must be public. at org.junit.internal.runners.rules.RuleFieldValidator.addError(RuleFieldValidator.java:90) at org.junit.internal.runners.rules.RuleFieldValidator.validatePublic(RuleFieldValidator.java:67) at org.junit.internal.runners.rules.RuleFieldValidator.validateField(RuleFieldValidator.java:55) at org.junit.internal.runners.rules.RuleFieldValidator.validate(RuleFieldValidator.java:50) at org.junit.runners.BlockJUnit4ClassRunner.validateFields(BlockJUnit4ClassRunner.java:170) at org.junit.runners.BlockJUnit4ClassRunner.collectInitializationErrors(BlockJUnit4ClassRunner.java:103) at org.junit.runners.ParentRunner.validate(ParentRunner.java:344) at org.junit.runners.ParentRunner.<init>(ParentRunner.java:74) at org.junit.runners.BlockJUnit4ClassRunner.<init>(BlockJUnit4ClassRunner.java:55) at android.support.test.internal.runner.junit4.AndroidJUnit4ClassRunner.<init>(AndroidJUnit4ClassRunner.java:38) at android.support.test.runner.AndroidJUnit4.<init>(AndroidJUnit4.java:36) at java.lang.reflect.Constructor.constructNative(Native Method) at java.lang.reflect.Constructor.newInstance(Constructor.java:417) at android.support.test.internal.runner.junit4.AndroidAnnotatedBuilder.buildAndroidRunner(AndroidAnnotatedBuilder.java:57) at android.support.test.internal.runner.junit4.AndroidAnnotatedBuilder.runnerForClass(AndroidAnnotatedBuilder.java:45) at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:57) at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:29) at org.junit.runner.Computer.getRunner(Computer.java:38) at org.junit.runner.Computer$1.runnerForClass(Computer.java:29) at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:57) at …