{} The code requires FirebaseApp and FirebasePe" /> {} The code requires FirebaseApp and FirebasePe" /> {} The code requires FirebaseApp and FirebasePe"/>

How to ignore AddTrace() for FirebasePerf during testing

93 Views Asked by At
    @AddTrace(name = "getCustomers")
    override suspend fun getCustomers(isDeleted: Boolean): List<Customer> {}

The code requires FirebaseApp and FirebasePerf but I don't need them. I am mocking the other Firebase properties required.

How would I ignore @addTrace when calling the function during test.

1

There are 1 best solutions below

0
Pseudo On

I had this problem, and a weird solution : In my build.gradle.kts, I check if I'm in a test context, and I set the setInstrumentationEnabled property according to.

val isEnable = !gradle.startParameter.taskNames.toString().contains("test")
android {
    //...
    buildTypes {
        getByName("The name of your build type") {
            //...
            withGroovyBuilder { "FirebasePerformance" { invokeMethod("setInstrumentationEnabled", isEnable) } }
        }
    }
}