2014-09-12 4 views
0

내가 사용하고 org.fest.reflect.exception.ReflectionError: Unable to find method '$$robo$getData' 에러 그것의 저를주는 테스트를 실행

@Before 
    public void setUp() throws Exception { 
     Activity activity = Robolectric.buildActivity(ActivityMain.class).create().get(); 

    } 

이후

을 wrtting하고 eclipse android에 대한 robolectric 테스트 테스트 용 개미 빌드

그러나이 코드 내 테스트와 함께 잘 작동

@Test 
    public void testBasicResourceValue() throws Exception { 
     String helloFromActivity = new ActivityMain().getResources().getString(R.string.str_my_file); 
     assertThat(helloFromActivity, equalTo("newfile")); 
    } 

그래서 그 프로그램이 AndroidManifest.xml

답변

0

Activity activity = Robolectric.buildActivity(ActivityMain.class).create().get(); this line is not working with ANT build i dont know why? i heard robolectric is stopped supporting ANT.So i found a another workaround for this problem to get the shadow object of the activity by using this code given below

@Before 
    public void setUp() throws Exception { 
     MyActivity activity = new MyActivity(); 
     //Remember setContentView() has to call before you are trying to get any resource ID from the activity like Button,TextView etc other wise you will get the not shadow object for those views. 
     activity.setContentView(R.layout.warning); 
     Assert.assertNotNull(activity); 

    } 
을 얻을 수 있음을 확인
관련 문제