Does Robolectric support API level?

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.

Leave a Comment