Does Robolectric support API level?

前端 未结 3 1654
轻奢々
轻奢々 2020-12-29 19:32

I have some Test which I would like to run with Robolectric, I use the 2.3-SNAPSHOT as my APP uses the ActionbarCompat i needed to use 2.3-SNAPSHOT Version as Robolectric co

3条回答
  •  隐瞒了意图╮
    2020-12-29 19:46

    Update: The annotation is now @Config(sdk = 18) (or @Config(sdk = Build.VERSION_CODES.JELLY_BEAN_MR2)) and the properties file mentioned in link is now robolectric.properties.

    Original Answer: You can use the @Config annotation to have Robolectric emulate an SDK version. You can put this :

    import org.robolectric.annotation.Config;
    
    @Config(emulateSdk = 18) // now @Config(sdk = 18) as of Robolectric 3.0
    @RunWith(RobolectricTestRunner.class)
    public class SomeTest ...
    

    This is also possible using a file as mentioned here

    Not sure what it means for your KitKat specific tests but at least the others should work.

提交回复
热议问题