Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/231.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 可与Robolectric 2序列化的测试包_Android_Robolectric_Android Testing - Fatal编程技术网

Android 可与Robolectric 2序列化的测试包

Android 可与Robolectric 2序列化的测试包,android,robolectric,android-testing,Android,Robolectric,Android Testing,我想测试我的类是否在包中写入了正确的数据,因此我编写了以下测试: @Test public void parcelOutAndIn() { Trip trip = new Trip("id123", new Date()); Parcel parcel = Parcel.obtain(); trip.writeToParcel(parcel, 0); Trip tripResult = new Trip(parcel); Assert.assertTh

我想测试我的类是否在包中写入了正确的数据,因此我编写了以下测试:

@Test
public void parcelOutAndIn() {
    Trip trip = new Trip("id123", new Date());

    Parcel parcel = Parcel.obtain();
    trip.writeToParcel(parcel, 0);
    Trip tripResult = new Trip(parcel);

    Assert.assertThat(tripResult.getId(), equalTo(trip.getId()));
    Assert.assertThat(tripResult.getStartTime(), equalTo(trip.getStartTime()));
}
我的writeToParcel如下所示:

@Override
public void writeToParcel(Parcel parcel, int i) {
    parcel.writeString(id);
    parcel.writeSerializable(startTime);
}
我有以下错误:

java.lang.NoSuchMethodError:java.util.Arrays.checkOffsetAndCount

我能做什么?这是机器人分子里的一只虫子吗? 我使用Robolectric 2.1.1

堆栈跟踪:

java.lang.NoSuchMethodError: java.util.Arrays.checkOffsetAndCount(III)V
at android.os.Parcel.writeByteArray(Parcel.java:472)
at android.os.Parcel.writeByteArray(Parcel.java:457)
at android.os.Parcel.writeSerializable(Parcel.java:1277)
at de.telekom.connectedcar.shuttle.driver.model.Trip.writeToParcel(Trip.java:92)
at de.telekom.connectedcar.shuttle.driver.model.TripTest.parcelOutAndInUsingCreator(TripTest.java:48)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.robolectric.RobolectricTestRunner$2.evaluate(RobolectricTestRunner.java:241)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.robolectric.RobolectricTestRunner$1.evaluate(RobolectricTestRunner.java:177)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.junit.runner.JUnitCore.run(JUnitCore.java:160)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)

不幸的是,Roboelectric的ShadowParcel没有包括writeByteArray()方法的实现


此处有一个活动的拉取请求:

如果您发布完整的崩溃日志,这会有所帮助。如果您指的是stacktrace,请参阅: