I am trying to write some tests for my Compose app...
# compose
y
I am trying to write some tests for my Compose app but I am getting
Default FirebaseApp is not initialized in this process com.livingmaples.videoplayer.test. Make sure to call FirebaseApp.initializeApp(Context) first.
I have other AndroidTests in my projects and they dont have this issue
my test code is this:
Copy code
class HomeHighlightTest {

    @get:Rule
    val composeTestRule = createComposeRule()

    @ExperimentalCoilApi
    @Test
    fun home_screen_test() {
        val vidPreviewModel = VidPreviewModel(
            id = "id",
            caption = "caption",
            description = "desc",
            thumbnailUrl = ""
        )
        composeTestRule.setContent {
            HomeHighlight(
                navController = rememberNavController(),
                vid = vidPreviewModel
            )
        }
        composeTestRule.onNodeWithText(vidPreviewModel.caption).assertExists()
    }

}
I watched a video that explained how we should write tests for Compose and it used
createAndroidComposeRule
but it requires an Activity param which I dont have access to (library module)
In my test code, I do not use any Firebase related code - I still get this exception even if my content is {}
c
I'm assuming it's still starting your application class which has firebase.
y
but why and how?
1
It doesnt matter what composable I use in the test, it always gets the exception, and I dont have this issue for my non compose AndroidTests
I could not find any relevant information on StackOverflow as well
Hopefully a compose developer/expert sees this 😩
1