Question

I'm just getting started with Robotium. However I seem to have run into a weird issue. Here is my test code.

    public class TestMaindashboard extends ActivityInstrumentationTestCase2<AboutActivity>{

    private Solo solo;
    public TestMaindashboard() {
        super(AboutActivity.class);
    }

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

    public void testSamp(){
        solo.assertCurrentActivity("Wrong activity", AboutActivity.class);
        List<View> viewList = solo.getCurrentViews();


            //More colde below
    }

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

The test throws a Null pointer exception at solo.getCurrentViews().

The exception thrown is

java.lang.NullPointerException
at com.jayway.android.robotium.solo.ViewFetcher.getNonDecorViews(ViewFetcher.java:161)
at com.jayway.android.robotium.solo.ViewFetcher.getAllViews(ViewFetcher.java:85)
at com.jayway.android.robotium.solo.ViewFetcher.getViews(ViewFetcher.java:192)
at com.jayway.android.robotium.solo.Solo.getCurrentViews(Solo.java:1477)
at com.example.myproject.test.TestMaindashboard.testSamp(TestMaindashboard.java:36)
at java.lang.reflect.Method.invokeNative(Native Method)
at android.test.InstrumentationTestCase.runMethod(InstrumentationTestCase.java:214)
at android.test.InstrumentationTestCase.runTest(InstrumentationTestCase.java:199)
at android.test.ActivityInstrumentationTestCase2.runTest(ActivityInstrumentationTestCase2.java:192)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:191)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:176)
at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:554)
at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1701)

Can someone point out what I'm doing wrong ? Thanks.

Was it helpful?

Solution

You should update your Robotium version to 5.1.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top