我有一些要与Robolectric一起运行的测试,我使用2.3-SNAPSHOT,因为我的APP使用的是ActionbarCompat,而我需要使用2.3-SNAPSHOT版本,因为Robolectric以前找不到AppCompat主题。因此,我在Eclipse中设置了类路径,最终得到了以下结果:
java.lang.UnsupportedOperationException: Robolectric does not support API level 9, sorry!
at org.robolectric.SdkConfig.<init>(SdkConfig.java:24)
at org.robolectric.RobolectricTestRunner.pickSdkVersion(RobolectricTestRunner.java:288)
at org.robolectric.RobolectricTestRunner.getEnvironment(RobolectricTestRunner.java:264)
at org.robolectric.RobolectricTestRunner.access$100(RobolectricTestRunner.java:57)
at org.robolectric.RobolectricTestRunner$2.evaluate(RobolectricTestRunner.java:186)
at org.junit.runners.BlockJUnit4ClassRunner.runNotIgnored(BlockJUnit4ClassRunner.java:79)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:71)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
at org.robolectric.RobolectricTestRunner$1.evaluate(RobolectricTestRunner.java:172)
at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
我的测试项目清单如下:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.vendor.test"
android:versionCode="1"
android:versionName="1.0">
<application>
<uses-library android:name="android.test.runner" />
</application>
<uses-sdk android:minSdkVersion="19" android:targetSdkVersion="19" />
<instrumentation android:name="android.test.InstrumentationTestRunner"
android:targetPackage="com.vendor" />
</manifest>
无论我使用什么,我总是抱怨API级别。
任何人都可以工作吗?