2013-03-26 3 views
1

사실 나는 UIautomator 테스트를 처음 사용합니다. 나는 시험을 봐야만하는 수업을 만들었습니다. 어느 누구도 내 UIAutomator 테스트 케이스 클래스를 어떻게 만들 수 있습니까? 내가 좋아하는 몇 가지 오류 ...RunTimeException UIAutomator에서 안드로이드 테스트

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:1661) 
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:4382) 
at android.app.ActivityThread.access$1300(ActivityThread.java:141) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1294) 
at android.os.Handler.dispatchMessage(Handler.java:99) 
at android.os.Looper.loop(Looper.java:137) 
at android.app.ActivityThread.main(ActivityThread.java:5041) 
at java.lang.reflect.Method.invokeNative(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560) 
at dalvik.system.NativeStart.main(Native Method) 
Caused by: java.lang.RuntimeException: Stub! 
at com.android.uiautomator.testrunner.UiAutomatorTestCase.<init>(UiAutomatorTestCase.java:5) 
at com.example.automatorapp.test.Test2.<init>(Test2.java:11) 
... 18 more 

을 가지고 내 코드는

 package com.example.automatorapp.test; 

    import com.android.uiautomator.core.UiObjectNotFoundException; 
    import com.android.uiautomator.testrunner.UiAutomatorTestCase; 

public class Test2 extends UiAutomatorTestCase 
{ 

    public Test2() 
    { 
    super(); 
    } 

    public void testDemo() throws UiObjectNotFoundException 
    { 

     getUiDevice().pressHome(); 

    } 


} 

이 PLZ 몇 가지 중 하나가 나를 도와입니다 ... ??

+0

문제는 생성자에'슈퍼()'null 값으로 전달 될 수 없습니다. – NullPointer

+0

하지만 생성자에서 일부 값을 전달하면 오류가 발생합니다. – Aditya

+0

생성자를 제거하면 필요 없습니다. – NullPointer

답변

2

nullpointer가 이미 표시 했으므로 생성자를 제거해야합니다. 여기

이 개정 (I 컴파일하고 성공적으로 실행 한) 코드는 다음의 경우

package com.example.automatoapp.test; 

import com.android.uiautomator.core.UiObjectNotFoundException; 
import com.android.uiautomator.testrunner.UiAutomatorTestCase; 


public class Test2 extends UiAutomatorTestCase 
{ 
    public void testDemo() throws UiObjectNotFoundException 
    { 
     getUiDevice().pressHome(); 
    } 
} 

이며, 모든 명령이 아닌 IDE에서, 명령 줄에서 실행됩니다

다음

은 어떻게 나는 장치 ant clean build && adb push bin/UIAutomatorExample.jar /data/local/tmp/

에 UIAutomator 코드를 밀어 & 컴파일 그리고 '당신의 "테스트 실행 방법 adb shell uiautomator runtest UIAutomatorExample.jar -c com.example.automatoapp.test.Test2

여기에 완성도를 들어

이 출력됩니다 :

INSTRUMENTATION_STATUS: current=1 
INSTRUMENTATION_STATUS: id=UiAutomatorTestRunner 
INSTRUMENTATION_STATUS: class=com.example.automatoapp.test.Test2 
INSTRUMENTATION_STATUS: stream= 
com.example.automatoapp.test.Test2: 
INSTRUMENTATION_STATUS: numtests=1 
INSTRUMENTATION_STATUS: test=testDemo 
INSTRUMENTATION_STATUS_CODE: 1 
INSTRUMENTATION_STATUS: current=1 
INSTRUMENTATION_STATUS: id=UiAutomatorTestRunner 
INSTRUMENTATION_STATUS: class=com.example.automatoapp.test.Test2 
INSTRUMENTATION_STATUS: stream=. 
INSTRUMENTATION_STATUS: numtests=1 
INSTRUMENTATION_STATUS: test=testDemo 
INSTRUMENTATION_STATUS_CODE: 0 
INSTRUMENTATION_STATUS: stream= 
Test results for WatcherResultPrinter=. 
Time: 1.535 

OK (1 test) 


INSTRUMENTATION_STATUS_CODE: -1 
관련 문제