Skip to content Skip to sidebar Skip to footer

Buildconfigfield Mock For Unit Test In Kotlin

I'm trying to cover as much as possible a Kotlin Android library and I'm encountering an issue about custom BuildConfig variable, better known as buildConfigField. I would like to

Solution 1:

ReflectionHelpers.setStaticField(BuildConfig::class.java, "ENABLE_LOG", true)

Solution 2:

By default, all tests run against the debug build type. You can change this to another build type by using the testBuildType property in your module-level build.gradle file. For example, if you want to run your tests against your "staging" build type, edit the file as shown in the following snippet.

android { ... testBuildType "staging" } but this is causing other options to fail

Post a Comment for "Buildconfigfield Mock For Unit Test In Kotlin"