首先,我想声明我对Android中缺乏适当的测试基础设施感到沮丧...或者也许是我太笨了,我不知道...
最终,我成功地设置了android-test-plugin,并为一个包含一个
所有尝试使用下面代码获取此活动实例的测试都通过了:
有没有解决此问题的方法? 非常感谢您的帮助。
最终,我成功地设置了android-test-plugin,并为一个包含一个
CustomMapFragment
的活动编写了几个测试用例。这个CustomMapFragment
是我编写的一个类,它扩展了SupportMapFragment
。所有尝试使用下面代码获取此活动实例的测试都通过了:
activity = Robolectric.buildActivity(MyActivity.class).create().get();
出现错误:
java.lang.NoClassDefFoundError: com/google/android/gms/maps/GoogleMap$OnInfoWindowClickListener
在活动的setContentView
方法中。
该活动的xml如下:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MyActivity">
<fragment
android:id="@+id/customMapFragment"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
class="com.myproject.CustomMapFragment"/>
</RelativeLayout>
有没有解决此问题的方法? 非常感谢您的帮助。