3

I'm trying to run simple testcase in eclipse, but I get next error:

Android Launch!
adb is running normally.
Performing android.test.InstrumentationTestRunner JUnit launch
Application already deployed. No need to reinstall.
Launching instrumentation android.test.InstrumentationTestRunner on emulator-5554
Test run failed: Instrumentation run failed due to 'java.lang.ClassNotFoundException'

Robotium lib is included. Apk file is resigned and installed. Test class has name "TestClass.java". Package name - com.android.opera.test.

Main activity and package name for the apk - com.opera.browser.

I read all similar answers here, but any didn't solve my problem. Code:

package com.android.opera.test;

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

@SuppressWarnings("rawtypes")
public class TestClass extends ActivityInstrumentationTestCase2 {
    private static final String TARGET_PACKAGE_ID = "com.opera.browser";
    private static final String LAUNCHER_ACTIVITY_FULL_CLASSNAME = "com.opera.browser.com.opera.browser";

    private static Class<?> launcherActivityClass;

    private Solo solo;

    static{
        try{
            launcherActivityClass=Class.forName(LAUNCHER_ACTIVITY_FULL_CLASSNAME);
        } catch (ClassNotFoundException e){
            System.out.println(e.getStackTrace());
            throw new RuntimeException(e);       
        }
    }

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

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

    public void testCaseTakeScreenshot() throws InterruptedException {
        solo.takeScreenshot("D://screenTest22!!!!.jpg");
        solo.clickOnScreen(50, 50);
    }

    @Override 
    public void tearDown() throws Exception
    {
        solo.finishOpenedActivities();
    }
}

manifest file:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.android.opera.test"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk android:minSdkVersion="14" />

    <instrumentation
        android:name="android.test.InstrumentationTestRunner"
        android:targetPackage="com.opera.browser" />

    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name" >
        <uses-library android:name="android.test.runner" />
    </application>

    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

</manifest>

Could anybody help me?

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.