2011-09-19 9 views
0

나는이 튜토리얼 ::SuperNotCalledException 실행 단위 테스트

http://developer.android.com/resources/tutorials/testing/helloandroid_test.html

다음이 안드로이드 단위 테스트를 실행하려고하고 그렇게에서하고는 SuperNotCalledException 여기

을 테스트 클래스 코드가 있어요 얻을 ::

package com.example.helloandroid2.test; 

import android.test.ActivityInstrumentationTestCase2; 
import android.widget.TextView; 

import com.example.helloandroid2.HelloAndroid2Activity; 

public class HelloAndroid2Test extends ActivityInstrumentationTestCase2<HelloAndroid2Activity> 
{ 
    private HelloAndroid2Activity mActivity; 
    private TextView mView; 
    private String resourceString; 

    public HelloAndroid2Test() 
    { 
     super("com.example.helloandroid2", HelloAndroid2Activity.class); 
    } 

    @Override 
    protected void setUp() throws Exception 
    { 
     super.setUp(); 
     mActivity = this.getActivity(); 
     mView = (TextView) mActivity.findViewById(com.example.helloandroid2.R.id.textview); 
     resourceString = mActivity.getString(com.example.helloandroid2.R.string.hello); 
    } 

    public void testPreconditions() 
    { 
      assertNotNull(mView); 
    } 

    public void testText() 
    { 
      assertEquals(resourceString,(String)mView.getText()); 
    } 
} 

실제로 내가 2_3_1에서 프로젝트 API 레벨을 설정 한 동일한에서 설정된 AVD를 사용하고

package com.example.helloandroid2; 

import android.app.Activity; 
import android.os.Bundle; 
import android.widget.TextView; 

public class HelloAndroid2Activity extends Activity { 
    /** Called when the activity is first created. */ 
    @Override 
    public void onCreate(Bundle savedInstanceState) { 
     setContentView(R.layout.main); 

    } 
} 

:: 테스트하고있어 클래스입니다. Windows Vista에서 ADT로 Eclipse를 실행 중입니다.

모든 지혜가 아주 좋았습니다. 미리 감사드립니다.

크리스

답변

4

HelloAndroid2Activity 요구에 대한 여러분의 onCreate() 방법은 호출 super.onCreate(savedInstanceState);

2
public class HelloAndroid2Activity extends Activity { 
    /** Called when the activity is first created. */ 
    @Override 
    public void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.main); 

    } 
}