Robotium的Android JUnit测试错误

时间:2018-08-17 03:35:42

标签: android junit robotium junit-runner

Enter image description here

android jnuit测试项目

import ***
....
@SuppressWarnings("rawtypes")
public class LoginTest extends ActivityInstrumentationTestCase2 {
    public Solo solo;
    public Activity activity;
    private static Class<?> launchActivityClass;
    private static String mainActiviy = "com.tencent.mm.ui.LauncherUI";
    private static String packageName = "com.tencent.mm";
    static {
        try {
            launchActivityClass = Class.forName(mainActiviy);
        } catch (ClassNotFoundException e) {
            throw new RuntimeException(e);
        }
    }
    @SuppressWarnings("unchecked")
    public LoginTest() {
        super(packageName, launchActivityClass);
    }
    @Override
    protected void setUp() throws Exception {
        super.setUp();
        this.activity = this.getActivity();
        this.solo = new Solo(getInstrumentation(), getActivity());
    }
    public void testLoginWithIncorrentUsernameAndPassword() throws Exception {
        TimeUnit.SECONDS.sleep(5);
    //......    
    }
    @Override
    public void tearDown() throws Exception {
        try {
            this.solo.finishOpenedActivities();
        } catch (Throwable e) {
            e.printStackTrace();
        }
        this.activity.finish();
        super.tearDown();
    }
}

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.android.notepad.test.test.test"
    android:versionCode="1"
    android:versionName="1.0" >
    <uses-sdk android:minSdkVersion="18" />
    <instrumentation
        android:name="android.test.InstrumentationTestRunner"
        android:targetPackage="com.tencent.mm" />
    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name" >
        <uses-library android:name="android.test.runner" />
    </application>
</manifest>

月食错误按摩:

  

在“启动LoginTest”期间发生内部错误。   org.eclipse.jdt.internal.junit.runner.IVisitsTestTrees.visitTreeEntry(Lorg / eclipse / jdt / internal / junit / runner / ITestIdentifier; ZI)V

0 个答案:

没有答案