Robolectric and Android SDK 29

前端 未结 4 1854
闹比i
闹比i 2020-12-29 19:51

When will Robolectric be compatible with Android SDK 29? Did I upgraded too early by changing targetSdkVersion and compileSdkVersion to 29?

4条回答
  •  生来不讨喜
    2020-12-29 20:09

    With Robolectric 4.3.1 we can use the following alternatives:

    1. Run our test with Java 9 or newer. (We can edit the JRE in the run test configuration)

    If we like to run our test with Java 8, we can:

    1. Annotated our test class with @Config in order to emulate a lower SDK (as mentioned by @bencri and @julio-mendoza).

    Like this:

    @RunWith(AndroidJUnit4::class)
    @Config(sdk = [Build.VERSION_CODES.P])
    class LoginRobolectricTest {
    //...
    }
    
    1. Or, as mentioned @farmerbb, add the robolectric.properties file inside the app/src/test/resources folder with the SDK we like to run, by example:

    sdk=28

提交回复
热议问题