unit testing - Context cannot be cast to Activity (Android instrumented tests) -


i trying test android app multiple languages (over 40). application behavior configurable firebase remote config - parameters set device locale condition.

my test case requires context cast activity execute production code:

mfirebaseremoteconfig.fetch(cacheexpiration)             .addoncompletelistener((activity) context, new oncompletelistener<void>()             {                 ...             } 

i have tried context defined in following way:

context appcontext = instrumentationregistry.gettargetcontext(); 

but throws:

java.lang.classcastexception: android.app.contextimpl cannot cast android.app.activity 

is there simple way achieve this?


Comments

Popular posts from this blog

python - Operations inside variables -

Generic Map Parameter java -

arrays - What causes a java.lang.ArrayIndexOutOfBoundsException and how do I prevent it? -