Bradleycorn
07/22/2022, 1:34 PMandroid.content.ActivityNotFoundException: Unable to find explicit activity class {com.myapp.android.test/androidx.test.core.app.InstrumentationActivityInvoker$BootstrapActivity}
Anyone run into this before? I’ve found a few things that mention adding the activity to the manifest in your androidTest folder, but I don’t have a manifest there, and have never needed one before. Not sure why I would need one now …nglauber
07/22/2022, 2:30 PMval context: Context
get() = ApplicationProvider.getApplicationContext()
Bradleycorn
07/22/2022, 2:39 PMnglauber
07/22/2022, 2:40 PMandroidTest
folder?Bradleycorn
07/22/2022, 2:42 PMBradleycorn
07/22/2022, 2:44 PMnglauber
07/22/2022, 2:45 PMtestInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
and these dependencies
testImplementation "junit:junit:$junit_version"
androidTestImplementation "androidx.test.ext:junit:$ext_junit_version"
androidTestImplementation "androidx.test.espresso:espresso-core:$expresso_core_version"
// Test rules and transitive dependencies:
androidTestImplementation("androidx.compose.ui:ui-test-junit4:$compose_version")
// Needed for createComposeRule, but not createAndroidComposeRule:
debugImplementation("androidx.compose.ui:ui-test-manifest:$compose_version")
This is what I have and my tests are working fine… (better than I expect)Bradleycorn
07/22/2022, 2:48 PMclass HiltTestRunner: AndroidJUnitRunner() {
override fun newApplication(cl: ClassLoader?, name: String?, context: Context?): Application {
return super.newApplication(cl, HiltTestCdiApplication_Application::class.java.name, context)
}
}
And thus my runner is setup accordingly:
testInstrumentationRunner "com.myapp.android.HiltTestRunner"
Bradleycorn
07/22/2022, 3:12 PMAndroidJUnitRunner
, and created a basic test like this:
@RunWith(AndroidJUnit4::class)
class ComposeDemoTest {
/**
* A ComposeContentTestRule for testing Composable functions.
*/
@get:Rule()
var composeTestRule = createComposeRule()
@OptIn(ExperimentalComposeUiApi::class, ExperimentalMaterialApi::class)
@Before
fun initializeUI() {
composeTestRule.setContent {
Text("This is a test")
}
}
@Test
fun demoTest() {
composeTestRule.onRoot().printToLog("Tree")
}
}
And it STILL fails with the missing BootstratpActivity …