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

sql - Time in datatime field -

javascript - How to split the success output from an Ajax post? -

java - sharing object across different classes -