mardi 28 juin 2016

Stub value of Build.VERSION.SDK_INT in Local Unit Test

I am wondering if there is anyway to stub the value of Build.Version.SDK_INT? Suppose I have the following lines in the ClassUnderTest:

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
    //do work
}else{
    //do another work
}

How can I cover all the code ?

I mean I want to run two tests with different SDK_INT to enter both blocks.

Is it possible in android local unit tests using Mockito/PowerMockito?

Thanks

Aucun commentaire:

Enregistrer un commentaire