https://kotlinlang.org logo
#mockk
Title
# mockk
a

Anthony f

01/21/2019, 5:07 PM
Does one you already succeed to mock Build.VERSION.SDK_INT ?
t

tKw

01/21/2019, 5:27 PM
You could try mocking
android.os.SystemProperties
and control the return for
getInt( "ro.build.version.sdk", 0)
. I am not an android developer and this is a guess based on limited research.
a

Anthony f

01/21/2019, 5:33 PM
@tKw thanks, but I do not want run InstrumentationTest, I target unit kotlin test. So I think I need to mock a more direct access either Version or directly the field.
t

tKw

01/21/2019, 5:43 PM
That appears to be the method call for getting the value of
Build.VERSION.SDK_INT
. That is where I would start at least. What have you attempted so far?
a

Anthony f

01/21/2019, 5:49 PM
SystemProperties is not accessible in Java, and in Kotlin this is a final private object
299 Views