I am providing my own implementation of Application
by creating a subclass and specifying the fully-qualified name of this subclass as the android:name
attribute in AndroidManifest.xml
's <application>
tag as:
<application
android:name=".GeniuzApp"
...
Running this Android App I can get the correct Application
object in an Activity
such as: val app = application as GeniuzApp
Yet, when I call ApplicationProvider.getApplicationContext
in a unit test, which is configured with @RunWith(RobolectricTestRunner::class)
, I am not getting an instance of my Application
subclass (i.e. GeniuzApp
).
Do I need to provide anything else on my unit test to get the correct application instance?
I was missing the following in
build.gradle
:as stated in Building with Android Studio/Gradle