2012-12-26 2 views
5

Android 애플리케이션 테스트를 처음 사용했습니다. 자바 코드를 사용하여 자동화 프레임 워크를 만들었습니다. 그런 다음 기존 Robotium Test App과 프레임 워크를 통합하려고했습니다. 내가 Run as 줄 때 후 ->Android Junit을 테스트 응용 프로그램이 성공적으로 설치됩니다하지만 예외 두 개의 자바 클래스를 가지고이라면 .. 닥터 버크 Exception during Suite construction.

가 발생합니다 - 예를 들어 Class1_Functional 라이브러리와 Class2_Automation 프레임 워크를. Robotium 프레임 워크 내에서 클래스 Class2_Automation Framework의 객체를 만들었으므로 클래스 내부에서 선언 된 함수를 호출하여 예외가 발생했다고 생각할 수 있습니다.

는 아래의 코드는 내 Robotium 프레임 워크를 보여줍니다

package jp.list.app.test; 

    import java.io.IOException; 
    import java.util.Arrays; 
    import android.app.Activity; 

    import com.jayway.android.robotium.solo.Solo; 

    import android.test.ActivityInstrumentationTestCase2; 
    import android.util.Log; 
    import jp.list.app.test.Automation_Framework; 
    @SuppressWarnings("unchecked") 
    public class TestLogin1 extends ActivityInstrumentationTestCase2 
    { 

     ///////////////// 
     //Created the object of the class Automation framework where the exception occurs 
     //////////////// 

    private Automation_Framework autoobj = new Automation_Framework(); 
    private static final 
    String TARGET_PACKAGE_ID = "jp.list.app"; 
    private static final 
    String LAUNCHER_ACTIVITY_FULL_CLASSNAME ="jp.list.app.JPActivity"; 

    //Parameters used for the Automation Framework 
    String excel_path ="/mnt/sdcard/Automation_Framework_Robotium.xls"; 
// String excel_path ="C:\\Automation_Framework\\Automation_Framework_Robotium.xls"; 
    String screenshot_path ="/mnt/sdcard/Screenshots"; 
// String screenshot_path = "C:\\Automation_Framework\\Screenshots"; 
    String excelsheet_flow ="Execution_Flow"; 
    String excelsheet_data ="Data"; 
    int stepidindex_flow = 2 ; 
    int tobeexctdindex_flow = 3; 
    int funtionflowindex_flow = 6; 
    int statusindex_flow = 7; 
    int executioncommentsindex_flow = 8; 
    int stepidindex_data = 0; 
    int funtionnameindex_data = 1; 
    int dataindex_data = 2; 
    int elementidindex_data = 3; 

    private static Class<?>launcherActivityClass; 
    static{ 
    try 
    { 
    launcherActivityClass = Class.forName(LAUNCHER_ACTIVITY_FULL_CLASSNAME); 
    } 
    catch(ClassNotFoundException e) 
    { 
    throw new 
    RuntimeException(e); 
    } 
    } 
    @SuppressWarnings({ "unchecked", "deprecation" }) 
    public TestLogin1() throws ClassNotFoundException 
    { 
     super(TARGET_PACKAGE_ID,launcherActivityClass); 

    } 
    private Solo solo; 
    private Activity activity; 

    @Override 
    protected void setUp()throws Exception 
    { 
     super.setUp(); 
     this.activity=this.getActivity(); 
    this.solo = new Solo(getInstrumentation(),this.activity); 
    } 

    public void test_framework() 
    { 
     try { 
      autoobj.driver_function(excel_path, screenshot_path, excelsheet_flow, stepidindex_flow, tobeexctdindex_flow, funtionflowindex_flow, statusindex_flow, executioncommentsindex_flow, excelsheet_data, stepidindex_data, funtionnameindex_data, dataindex_data, elementidindex_data); 
     } catch (IOException e) { 
      Log.v("output", e.toString()); 
      e.printStackTrace(); 
     } catch (InterruptedException e) { 
      // TODO Auto-generated catch block 
      e.printStackTrace(); 
     } 

    } 
    @Override 
    public void tearDown()throws Exception 
    { 
    try 
    { 
    solo.finalize(); 
    } 
    catch(Throwable e) 
    { 
    e.printStackTrace(); 
    } 
    getActivity().finish(); 
    super.tearDown(); 
    } 
    } 

그리고 내 로그 캣 출력은

----- begin exception ----- 
       java.lang.RuntimeException: Exception during suite construction 
       at android.test.suitebuilder.TestSuiteBuilder$FailedToCreateTests.testSuiteConstructionFailed(TestSuiteBuilder.java:238) 
       at java.lang.reflect.Method.invokeNative(Native Method) 
       at java.lang.reflect.Method.invoke(Method.java:511) 
        at junit.framework.TestCase.runTest(TestCase.java:168) 
        at junit.framework.TestCase.runBare(TestCase.java:134) 
        at junit.framework.TestResult$1.protect(TestResult.java:115) 
        at junit.framework.TestResult.runProtected(TestResult.java:133) 
        at junit.framework.TestResult.run(TestResult.java:118) 
        at junit.framework.TestCase.run(TestCase.java:124) 
        at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:190) 
        at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:175) 
        at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:555) 
        at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1584) 
       Caused by: java.lang.reflect.InvocationTargetException 
        at java.lang.reflect.Constructor.constructNative(Native Method) 
       at java.lang.reflect.Constructor.newInstance(Constructor.java:417) 
        at android.test.suitebuilder.TestMethod.instantiateTest(TestMethod.java:87) 
        at android.test.suitebuilder.TestMethod.createTest(TestMethod.java:73) 
        at android.test.suitebuilder.TestSuiteBuilder.addTest(TestSuiteBuilder.java:262) 
       at android.test.suitebuilder.TestSuiteBuilder.build(TestSuiteBuilder.java:184) 
        at android.test.InstrumentationTestRunner.onCreate(InstrumentationTestRunner.java:379) 
        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4142) 
       at android.app.ActivityThread.access$1300(ActivityThread.java:130) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1255) 
        at android.os.Handler.dispatchMessage(Handler.java:99) 
        at android.os.Looper.loop(Looper.java:137) 
        at android.app.ActivityThread.main(ActivityThread.java:4745) 
        at java.lang.reflect.Method.invokeNative(Native Method) 
       at java.lang.reflect.Method.invoke(Method.java:511) 
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553) 
        at dalvik.system.NativeStart.main(Native Method) 
       Caused by: java.lang.VerifyError: jp/list/app/test/Function_Lib_Robotium 
       at jp.list.app.test.Automation_Framework.<init>(Automation_Framework.java:37) 
        at jp.list.app.test.TestLogin1.<init>(TestLogin1.java:15) 
        ... 18 more 
       ----- end exception ----- 

의 JUnit 예외 제공 :

java.lang.RuntimeException: Exception during suite construction 
       at android.test.suitebuilder.TestSuiteBuilder$FailedToCreateTests.testSuiteConstructionFailed(TestSuiteBuilder.java:238) 
       at java.lang.reflect.Method.invokeNative(Native Method) 
       at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:190) 
       at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:175) 
       at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:555) 
       at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1584) 
       Caused by: java.lang.reflect.InvocationTargetException 
       at java.lang.reflect.Constructor.constructNative(Native Method) 
       at java.lang.reflect.Constructor.newInstance(Constructor.java:417) 
       at android.test.suitebuilder.TestMethod.instantiateTest(TestMethod.java:87) 
       at android.test.suitebuilder.TestMethod.createTest(TestMethod.java:73) 
       at android.test.suitebuilder.TestSuiteBuilder.addTest(TestSuiteBuilder.java:262) 
       at android.test.suitebuilder.TestSuiteBuilder.build(TestSuiteBuilder.java:184) 
       at android.test.InstrumentationTestRunner.onCreate(InstrumentationTestRunner.java:379) 
       at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4142) 
       at android.app.ActivityThread.access$1300(ActivityThread.java:130) 
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1255) 
       at android.os.Handler.dispatchMessage(Handler.java:99) 
       at android.os.Looper.loop(Looper.java:137) 
       at android.app.ActivityThread.main(ActivityThread.java:4745) 
       at java.lang.reflect.Method.invokeNative(Native Method) 
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786) 
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553) 
       at dalvik.system.NativeStart.main(Native Method) 
       Caused by: java.lang.VerifyError: jp/list/app/test/Function_Lib_Robotium 
       at jp.list.app.test.Automation_Framework.<init>(Automation_Framework.java:37) 
       at jp.list.app.test.TestLogin1.<init>(TestLogin1.java:15) 
       ... 18 more 

와 함께 누군가가 나에게 제공 할 수 있다면 정말 감사하겠습니다을 위 쿼리에 대한 해결책.

+0

발생 원인 : java.lang.VerifyError : jp/list/app/test/Function_Lib_Robotium –

+0

이 오류는 4.2 장치에서만 발생합니다 ??? –

+0

글쎄, 답장을 보내 주셔서 감사합니다. Android 4.1.2 버전을 사용하고 있으며 다른 버전을 사용하지 않았습니다. –

답변

0

확률 적 이유가 될 수있다 :

  1. 그냥 당신이 JAR 파일을 포함했는지 확인합니다.

  2. 클래스 선언문은 다음과 같아야합니다. public class TestLogin1 extends ActivityInstrumentationTestCase2 여기서 T는 테스트 스위트가 실행되는 클래스 여야합니다. getActivity()가 테스트중인 활동을 가져

    this.solo = new Solo(getInstrumentation(),getActivity()); 
    

    : 사용자 설정() 메소드에서

  3. 은 문처럼되고있다.

희망이 있습니다.

0
@SuppressWarnings({ "unchecked", "deprecation" }) 
public TestLogin1() throws ClassNotFoundException 
{ 
    super(TARGET_PACKAGE_ID,launcherActivityClass); 

} 

이것은 이상합니다. 표준 생성자는

@SuppressWarnings({ "unchecked", "deprecation" }) 
public TestLogin1() throws ClassNotFoundException 
{ 
    super(JPActivity.class); 
} 
또한

ActivityInstrumentationTestCase2<JPActivity>의 일반적인 유형으로 JPActivity를 선언해야합니다.