우선 안드로이드에서 테스트 인프라의 부족에 대한 좌절감을 표하고 싶습니다. 아니면 어쩌면 저능아인지 모르겠지만 ...
궁극적으로는 android-test-plugin을 설정하고 나는 SupportMapFragment
을 확장 한 글자 인 CustomMapFragment
을 레이아웃에 포함하는 활동에 대한 몇 가지 테스트를 작성했습니다. 사용이 활동의 인스턴스를 얻으려고
내 모든 테스트 : 활동의 setContentView
에Robolectric 문제를 사용하여 Android Studio에서 안드로이드 테스팅
java.lang.NoClassDefFoundError: com/google/android/gms/maps/GoogleMap$OnInfoWindowClickListener
:
activity = Robolectric.buildActivity(MyActivity.class).create().get();
는 실패.
<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>
이것에 대한 해결 방법/솔루션이 있습니까 :
활동의 XML
은 다음과 같다? 도움이 될 것입니다.
커밋이있는 수정 프로그램을 적용하는 것입니다. Robolectric이 클래스를로드하려고 할 때 NoClassDefFoundError를 얻었 기 때문에 테스트를 실행할 수 없으므로 assertTrue (true) 테스트조차도 실패합니다. 여기에 오류가 내 질문에 http://stackoverflow.com/questions/18434217/robolectric-fails-to-run-tests-with-google-play-services-maps – alex
나는 그것이 일반적인 문제라고 생각한다. 지도에 연결되었습니다. 일부 클래스에서 Google 클라우드 메시징을 사용하는 곳에서 동일한 오류가 발생했기 때문입니다. 당신을 이해하는 사람들이 있다는 것을 아는 것은 좋은 일입니다 :) 만약 누군가가 여기에 대답하면 나는 당신에게 말할 것입니다. –
Google Play 서비스 의존성을 어떻게 추가 했습니까? Google 리포지토리를 사용하거나 다른 방법으로 사용 하시겠습니까? – alex