2

我有一个测试班,但总是进入NullPointerExceptiontearDown()有人知道为什么吗?

public class LaunchManagerActivityTest extends ActivityInstrumentationTestCase2<LaunchManagerActivity> {

    private Solo solo;

    public LaunchManagerActivityTest() {
        super(LaunchManagerActivity.class);
    }

    @Override
    protected void setUp() throws Exception {
        super.setUp();

        solo = new Solo(getInstrumentation(), getActivity());
    }

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

    public void testOne() {

    }

    public void testTwo() {

    }
4

1 回答 1

12
 @Override
    protected void tearDown() throws Exception {
        super.tearDown();
        solo.finishOpenedActivities();
    }

实际上应该是:

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

supers teardown 将关闭启动的活动,但 robotsium 随后会感到困惑,因为它认为活动是打开的,当它尝试对其进行操作时,它是空的。

于 2013-02-11T10:00:14.630 回答