austgl / robotium

Automatically exported from code.google.com/p/robotium
0 stars 0 forks source link

I have some problem when create and run android test project. Please help me. #145

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

package com.cieaura.test;

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

import android.app.Activity;
//import android.app.ActivityGroup;
import android.test.ActivityInstrumentationTestCase2;
import com.cieaura.R;
import com.cieaura.virtualoffice.activity.VOLogin;
import android.widget.EditText;
import android.widget.TextView;;

public class TestLogin extends ActivityInstrumentationTestCase2<VOLogin> {
    private Solo solo;
    private Activity activity;
    //private VOLogin vologin;
    //final VOLogin activity=this.getActivity();
    public TestLogin() {
        super("com.cieaura.virtualoffice.activity",VOLogin.class);
    }
@Override
    protected void setUp() throws Exception {
        super.setUp();
        this.solo = new Solo(getInstrumentation(),activity);
        System.out.println("There are" + this.countTestCases() + "test cases");
    }
@Override
protected void tearDown() throws Exception {
    try {
        //solo.goBack();
        solo.finalize();
        } catch (Throwable e) {
        e.printStackTrace();
        }
           activity.finish();
        //this.activity.finish();
        super.tearDown();

}

public void testAdd()
{
    //vologin=new VOLogin();
    String user123="abc";
    String pass123="1234";

    //solo.enterText(R.id.et_vo_login_username, user);
    //solo.enterText(R.id.et_vo_login_password, pass);
  EditText User=(EditText)solo.getView(R.id.et_vo_login_username);
    solo.enterText(User, user123);
  EditText User=(EditText)solo.getView(R.id.et_vo_login_password);
    solo.enterText(Pass, pass123);
}

}

What is the expected output? What do you see instead?

java.lang.NullPointerException
at com.cieaura.test.TestLogin.tearDown(TestLogin.java:35)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:169)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:154)
at 
android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:52
0)
at 
android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1447)

What version of the product are you using? On what operating system?

robo 2.4 and android 2.2
Please provide any additional information below.

Original issue reported on code.google.com by tranhong...@gmail.com on 30 Aug 2011 at 10:51

GoogleCodeExporter commented 9 years ago
Change:

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

to:

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

Original comment by renasr...@gmail.com on 31 Aug 2011 at 5:59

GoogleCodeExporter commented 9 years ago
Thanks you.
I try work with this.solo=new Solo(getInstrumentation(),getActivity());
But I also encounter this problem.

Original comment by tranhong...@gmail.com on 1 Sep 2011 at 1:37

GoogleCodeExporter commented 9 years ago
I try to change codes below:
package com.cieaura.test;

import com.jayway.android.robotium.solo.Solo;
import android.test.ActivityInstrumentationTestCase2;
import com.cieaura.R;
import android.widget.EditText;
import android.widget.LinearLayout;

@SuppressWarnings ("unchecked")
public class TestLogin extends ActivityInstrumentationTestCase2{

    private static final String TARGET_PACKAGE_ID = "com.cieaura";
    private static final String LAUNCHER_ACTIVITY_FULL_CLASSNAME = "com.cieaura.virtualoffice.activity.VOLogin";
    private Solo solo;
    private LinearLayout llTopBar;
    //private VOLogin voLogin;
    //private String resourceString;

    private static Class<?>launcherActivityClass;
    static {
        try {
            launcherActivityClass=Class.forName(LAUNCHER_ACTIVITY_FULL_CLASSNAME);
        }
        catch(ClassNotFoundException e)
        {

            throw new RuntimeException(e);
        }

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

    }

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

        //resourceString=voLogin.getString(com.cieaura.R.id.et_vo_login_username);
        System.out.println("There are" + this.countTestCases() + "test cases");
    }
@Override
protected void tearDown() throws Exception {
    try {
         solo.finalize();
        } catch (Throwable e) {
        e.printStackTrace();
        }
        getActivity().finish();
        super.tearDown();

}

public void testAdd()
{
    String user123="abc";
    String pass123="1234";
    llTopBar=(LinearLayout)solo.getTopParent(getActivity().findViewById(R.id.layout_top_bar));
    EditText user=(EditText)solo.getTopParent(getActivity().findViewById(R.id.et_vo_login_username));
    solo.enterText(user, user123);
    EditText pass=(EditText)solo.getTopParent(getActivity().findViewById(R.id.et_vo_login_password));
    solo.enterText(pass, pass123);
    solo.clickOnButton(R.id.btn_vo_login_signin);

}

}

and issues that I have in LogCat:
Test failed to run to completion. Reason: 'Instrumentation run failed due to 
'java.lang.NullPointerException''. Check device logcat for details

09-01 11:12:05.897: WARN/dalvikvm(456): threadid=1: thread exiting with 
uncaught exception (group=0x4001d800)
09-01 11:12:05.927: ERROR/AndroidRuntime(456): FATAL EXCEPTION: main
09-01 11:12:05.927: ERROR/AndroidRuntime(456): java.lang.RuntimeException: 
Unable to start activity 
ComponentInfo{com.cieaura/com.cieaura.virtualoffice.activity.VOLogin}: 
java.lang.NullPointerException
09-01 11:12:05.927: ERROR/AndroidRuntime(456):     at 
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
09-01 11:12:05.927: ERROR/AndroidRuntime(456):     at 
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
09-01 11:12:05.927: ERROR/AndroidRuntime(456):     at 
android.app.ActivityThread.access$2300(ActivityThread.java:125)
09-01 11:12:05.927: ERROR/AndroidRuntime(456):     at 
android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
09-01 11:12:05.927: ERROR/AndroidRuntime(456):     at 
android.os.Handler.dispatchMessage(Handler.java:99)
09-01 11:12:05.927: ERROR/AndroidRuntime(456):     at 
android.os.Looper.loop(Looper.java:123)
09-01 11:12:05.927: ERROR/AndroidRuntime(456):     at 
android.app.ActivityThread.main(ActivityThread.java:4627)
09-01 11:12:05.927: ERROR/AndroidRuntime(456):     at 
java.lang.reflect.Method.invokeNative(Native Method)
09-01 11:12:05.927: ERROR/AndroidRuntime(456):     at 
java.lang.reflect.Method.invoke(Method.java:521)
09-01 11:12:05.927: ERROR/AndroidRuntime(456):     at 
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
09-01 11:12:05.927: ERROR/AndroidRuntime(456):     at 
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
09-01 11:12:05.927: ERROR/AndroidRuntime(456):     at 
dalvik.system.NativeStart.main(Native Method)
09-01 11:12:05.927: ERROR/AndroidRuntime(456): Caused by: 
java.lang.NullPointerException
09-01 11:12:05.927: ERROR/AndroidRuntime(456):     at 
com.cieaura.virtualoffice.activity.VOLogin.onCreate(VOLogin.java:46)
09-01 11:12:05.927: ERROR/AndroidRuntime(456):     at 
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
09-01 11:12:05.927: ERROR/AndroidRuntime(456):     at 
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
09-01 11:12:05.927: ERROR/AndroidRuntime(456):     ... 11 more
09-01 11:12:05.947: WARN/ActivityManager(69): Error in app com.cieaura running 
instrumentation 
ComponentInfo{com.cieaura.test/android.test.InstrumentationTestRunner}:
09-01 11:12:05.947: WARN/ActivityManager(69):   java.lang.NullPointerException
09-01 11:12:05.947: WARN/ActivityManager(69):   java.lang.NullPointerException: 
Unable to start activity 
ComponentInfo{com.cieaura/com.cieaura.virtualoffice.activity.VOLogin}: 
java.lang.NullPointerException

Original comment by tranhong...@gmail.com on 1 Sep 2011 at 4:47

GoogleCodeExporter commented 9 years ago
.i am facing "Instrumentation run failed due to 
'java.lang.NullPointerException'", 
I am using default android junittest framwork.
in my case I am starting service class from activity...if I put some delay to 
start service then it's working..but if it's start without any delay then it's 
giving erroe...any suggestion here?

Original comment by shubhamP...@gmail.com on 19 Oct 2012 at 6:33

GoogleCodeExporter commented 9 years ago
05-28 17:22:51 I/0640000200000001: 
android.graphics2.cts.TextureViewTest#testTextureViewActivity FAIL 
Test failed to run to completion. Reason: 'Instrumentation run failed due to 
'java.lang.NullPointerException''. Check device logcat for details
05-28 17:22:53 I/0640000200000001: Saved log 
device_logcat_1675676680895097570.zip
05-28 17:22:53 I/0640000200000001: Saved log host_log_6178921336026032335.zip
05-28 17:22:53 I/0640000200000001: android.graphics2 package complete: Passed 
0, Failed 1, Not Executed 0

How to fix it??

Regards
Mukesh

Original comment by mukesh...@pathpartnertech.com on 28 May 2013 at 12:04

GoogleCodeExporter commented 9 years ago
Hi
GUI is not coming on the blaze Tablet ,i am using android 4.0.3 and kernel 
version 3.0.8.Once i touch the screen to bring the GUI it get restart.I tried 
several times,how to resolve it.Is there any driver problem ?.How to fix this?

Thanks in Advance !!!
Regards

Mukesh

Original comment by mukesh...@pathpartnertech.com on 28 May 2013 at 12:19