Reputation: 19240
I'm at the state where I want to write androidTests for the app.
Reading the docs of Testing Compose, I created a file and write a simple test to examine the progress:
ExamineTest.kt:
class ExamineTest {
@get:Rule
val composeTestRule = createComposeRule()
@Test
fun atLaunchDefaultTextExists() {
composeTestRule.setContent {
Text(text = "text")
}
composeTestRule.onNodeWithText("text").assertIsDisplayed()
}
}
Also I added the debug AndroidManifest
at the app/src/debug/
to enable ComposeActivity as suggested in docs.
However, by running the test nothing will happen and the test will not start executing.
Here's the state that test gets stock at (App is built and deployed. But not started to run tests. Normal execution of app works correctly):
Am I missing a part on the setup ? What is the reason that tests are not running?
compose: 1.0.0-alpha05 AS: 4.2-canary 14
After debugging the test and check it's logs, I see this error:
No method shouldWaitForActivitiesToComplete() in
androidx/test/runner/AndroidJUnitRunner
Upvotes: 3
Views: 1395
Reputation: 19240
Make sure
test:monitor
andtest:core
are up to date.
Checking out this issue on Android-test github, I realized the issue might be because of test:monitor
being older than needed. So I did these steps:
Check Gradle task app:dependencies
to see the version of test:monitor
library
If it's indeed old (which was 1.2.0
and not the latest 1.3.0
), find the library that downgrades it.
in my case fragment-testing
was downgrading it to 1.2
, so I removed it.
After making sure test:monitor
and test:core
are up to date, I could finally run the test
Upvotes: 1