Stack Overflow Asked by Mohamed Hamdan on November 29, 2021
I’m trying to run UI test that when click on the button should open another activity but that activity in another module and I’m open it using intent-filter action, the module which I want to run UI test on it is not know anything about the other module so when espresso clicks on the button ActivityNotFoundException
will be thrown, but it will not happen if I run the project without unit test it’s will work because app module implements both modules.
My Gradle project structure for the app module:
dependencies {
implementation project(":login")
implementation project(":main")
}
Login module
dependencies {
implementation project(':core')
}
Main module
dependencies {
implementation project(':core')
}
Both main and login doesn’t know anything about each other, and when I start the main activity from login activity I start it by intent action:
startActivity(Intent("com.example.Main"))
This is the manifest file for main module
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="com.example.Main" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
Because the app module implements both modules it will run without issues, but when starting the UI test it will crash with ActivityNotFoundException
because the app module will not start if I run the test from the submodule.
I have tried to add the main module to login module
dependencies {
implementation project(':core')
implementation project(':main')
}
But if I have in main module button that opens LoginActivity
and in the login module I have another button to open MainActivity
I can’t do something like this
Main:
dependencies {
implementation project(':core')
implementation project(':login')
}
Login:
dependencies {
implementation project(':core')
implementation project(':main')
}
it’s will be cyclic dependency
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP