vendredi 18 septembre 2015

Test failed to run to completion. Reason: 'Instrumentation run failed due to 'java.lang.NullPointerException''

I am learning to use android robotium and I am trying to make a simple test where it reads the first line of a file and it equals "car" but I am getting

Test failed to run to completion. Reason: 'Instrumentation run failed due to 'java.lang.NullPointerException''.

*The activity starts a fragment.

public class TestReadFromFile extends ActivityInstrumentationTestCase2<PagesActivity> {

private Solo solo;
PagesActivity mPagesActivity;

private Context mContext;


public TestReadFromFile() {
    super(PagesActivity.class);
}

public void testReadLine() throws Exception {

    assertEquals(ReadFromFile.readLine(0, mContext),
            "car");
}

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


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

Aucun commentaire:

Enregistrer un commentaire