gpt4 book ai didi

java - solo.finishOpenActivities() 始终为空

转载 作者:太空狗 更新时间:2023-10-29 15:36:43 26 4
gpt4 key购买 nike

我有一个测试类,但总是在 tearDown() 中得到一个 NullPointerException,有人知道为什么吗?

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() {

}

最佳答案

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

实际上应该是:

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

super 拆解将关闭已启动的 Activity,但 robotium 然后会感到困惑,因为它认为一个 Activity 是打开的,当它尝试对其执行某些操作时,它是空的。

关于java - solo.finishOpenActivities() 始终为空,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14809719/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com