0

i have .apk file and i want to test it using robotiun and i have followed the procedure but when i run the app using junit test i am getting an error as Test run failed: Instrumentation run failed due to 'Process crashed.'

This is my androidmanifest.xml:

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

My TestActivity.java file is

 @SuppressWarnings("unchecked") public class TestActivity extends ActivityInstrumentationTestCase2 { private static final String TARGET_PACKAGE_ID = "com.metago.astro"; private static final String LAUNCHER_ACTIVITY_FULL_CLASSNAME = "com.metago.astro.SplashActivity"; private static Class<?> launcherActivityClass; static { try { launcherActivityClass = Class .forName(LAUNCHER_ACTIVITY_FULL_CLASSNAME); } catch (ClassNotFoundException e) { throw new RuntimeException(e); } } public TestActivity() throws ClassNotFoundException { super(TARGET_PACKAGE_ID, Class.forName(LAUNCHER_ACTIVITY_FULL_CLASSNAME)); } private Solo solo; @Override protected void setUp() throws Exception { solo = new Solo(getInstrumentation(), getActivity()); } public void testCanOpenSettings() { solo.pressMenuItem(0); } @Override public void tearDown() throws Exception { solo.finishOpenedActivities(); } } 

My logcat is

 FATAL EXCEPTION: main java.lang.ExceptionInInitializerError at java.lang.Class.newInstanceImpl(Native Method) at java.lang.Class.newInstance(Class.java:1319) at android.app.Instrumentation.newActivity(Instrumentation.java:1023) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1871) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:137) at android.app.ActivityThread.main(ActivityThread.java:4424) 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:784) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551) at dalvik.system.NativeStart.main(Native Method) Caused by: java.lang.RuntimeException: java.lang.ClassNotFoundException: com.metago.astro.SplashActivity at com.metago.astro.TestActivity.<clinit>(TestActivity.java:19) ... 15 more Caused by: java.lang.ClassNotFoundException: com.metago.astro.SplashActivity at java.lang.Class.classForName(Native Method) at java.lang.Class.forName(Class.java:217) at java.lang.Class.forName(Class.java:172) at com.metago.astro.TestActivity.<clinit>(TestActivity.java:17) ... 15 more Caused by: java.lang.NoClassDefFoundError: com/metago/astro/SplashActivity Caused by: java.lang.ClassNotFoundException: com.metago.astro.SplashActivity at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61) at java.lang.ClassLoader.loadClass(ClassLoader.java:501) at java.lang.ClassLoader.loadClass(ClassLoader.java:461) ... 19 more 

Line no 17 is .forName(LAUNCHER_ACTIVITY_FULL_CLASSNAME);

3
  • Post the entire manifest for your test project Commented Aug 6, 2012 at 11:06
  • the android manifest.xml is also posted Commented Aug 6, 2012 at 11:07
  • The whole thing isn't there. Please make sure the whole manifest is there. Commented Aug 6, 2012 at 11:08

1 Answer 1

1

The package name for your test project needs to be different from the package name for the application you want to test. The package name must be a unique identifier. In your test application you should use something like package="com.metago.astro.test"

Also, you may need to add the following permission:

<uses-permission android:name="android.permission.RUN_INSTRUMENTATION" /> 
Sign up to request clarification or add additional context in comments.

12 Comments

it is saying that Test run failed: Unable to find instrumentation target package: com.metago.astro.test
No. Set targetPackage="com.metago.astro" but set package="com.metago.astro.test" in the first line of the manifest for the test project.
thanks sir, but i am getting another error as Test run failed: Instrumentation run failed due to 'Process crashed.'
What's in the logcat this time?
Post the manifest for both your test project and your target project. If you are using Eclipse please close Eclipse, restart it, clean your project, rebuild your project from scratch and wave a dead chicken over your head while praying to the God (or Gods) of your choice).
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.