This repository was archived by the owner on Feb 26, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
This repository was archived by the owner on Feb 26, 2023. It is now read-only.
Use generated classes in Kotlin tests #2082
Copy link
Copy link
Closed
Description
AndroidAnnotations version: 4.4.0
Android compile SDK version: 25
Annotated code: Empty Activity with @EActivity annotation
Actual generated code: Looks correct, no issues here.
We want to use AndroidAnnotation generated classes in tests (unit/instrumentation) but since Kotlin 1.1.3 this does not work anymore. Tests implemented in Java instead of Kotlin work fine however.
Easiest way to reproduce (unit test):
- Kotlin app project with AndroidAnnotations
- enhance an activity with annotation
@EActivity - write Kotlin unit test which creates an AndroidAnnotation generated activity instance (ExampleActivity_) and call
setContentView(null)- expected is a stacktrace which contains information about AndroidAnnotation generated activity class
- result is stacktrace with direct call to base class (skipping the generated one)
Other way to reproduce (instrumentation test):
This issue occurs also within Espresso tests. Espresso test references generated class, but it uses the base activity during runtime.
@Rule
@JvmField
val mActivityRule = ActivityTestRule(MyActivity_::class.java)java.lang.RuntimeException: Could not launch activity
at android.support.test.runner.MonitoringInstrumentation.startActivitySync(MonitoringInstrumentation.java:430)
at android.support.test.rule.ActivityTestRule.launchActivity(ActivityTestRule.java:332)
at android.support.test.rule.ActivityTestRule$ActivityStatement.evaluate(ActivityTestRule.java:431)
at org.junit.rules.RunRules.evaluate(RunRules.java:20)
...
at android.support.test.internal.runner.TestExecutor.execute(TestExecutor.java:58)
at android.support.test.runner.AndroidJUnitRunner.onStart(AndroidJUnitRunner.java:375)
at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1932)
Caused by: java.lang.RuntimeException: Unable to resolve activity for: Intent { act=android.intent.action.MAIN flg=0x10000000 cmp=com.company.myapp/.ui.MyActivity }
at android.app.Instrumentation.startActivitySync(Instrumentation.java:396)
at android.support.test.runner.MonitoringInstrumentation.access$101(MonitoringInstrumentation.java:96)
at android.support.test.runner.MonitoringInstrumentation$4.call(MonitoringInstrumentation.java:410)
at android.support.test.runner.MonitoringInstrumentation$4.call(MonitoringInstrumentation.java:407)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
...
Already tried:
- use different Kotlin versions
- with all Kotlin 1.1.2-* versions its works fine, with 1.1.3 this issue occurs
- with Kotlin 1.1.51 the issue still exists
- tools like dbflow looks working (possible not comparable)
Metadata
Metadata
Assignees
Labels
No labels