Troubleshooting Android Instrument Test Status Issues in Submodule Projects

Haris Weitani
2 min readApr 9, 2024

--

Project Setup : Android Native project that have submodule and parent module
Issue : Instrument test status not showing on SubModule only

TLDR — open Android Studio Settings -> Build, Execution, Deployment -> Testing -> uncheck the “Run Android Instrumanted Tests using Gradle”

Success with 0 Status

Recently, I’ve been working on Compose UI testing on Android and I encountered this issue.

Have you noticed anything unusual in the image above? Yes, the tests are passing, but the status itself is 0. Then if you ask me what happens if there are any errors in my UI tests?

Failed with 0 Status

Errors but still with 0 status. I‘m confused because just a few hours ago, when I was working on another UI test, everything was fine. I’ve tried running my other UI tests again, and they were normal.

Normal Success

So the issue is only in submodule

Based on this issue tracker https://issuetracker.google.com/issues/295509079

we just need to open the Android Studio Settings -> Build, Execution, Deployment -> Testing -> uncheck the “Run Android Instrumanted Tests using Gradle”

Solution

and now the status is showing the tests that we have

In case you guys wonder that maybe something is wrong with my code i put my UI test below

@RunWith(AndroidJUnit4::class)
class ExampleSubmodule {

@get:Rule
val composeTestRule = createComposeRule()

@Test
fun testOn_Parent_Success() {
composeTestRule.setContent {
Text(text = "SubModule Test")
}
composeTestRule.onNodeWithText("SubModule Test").assertIsDisplayed()
}

@Test
fun testOn_Parent_Error() {
composeTestRule.setContent {
Text(text = "Error")
}
composeTestRule.onNodeWithText("asddd").assertIsDisplayed()
}
}

What do you guys think?

if its helpful give it a clap! If you have any questions, I am more than happy to discuss.

--

--

Haris Weitani
Haris Weitani

Written by Haris Weitani

Hi, i'm software engineer that focused on Android! This page is my learning journey, please feel free to comment and any suggestion will be very welcome!