Issue
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
Update
After debugging the test and check it's logs, I see this error:
No method shouldWaitForActivitiesToComplete() in
androidx/test/runner/AndroidJUnitRunner
Solution
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 oftest:monitor
libraryIf it's indeed old (which was
1.2.0
and not the latest1.3.0
), find the library that downgrades it.in my case
fragment-testing
was downgrading it to1.2
, so I removed it.
After making sure test:monitor
and test:core
are up to date, I could finally run the test
Answered By - Mahdi-Malv
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.