0
我创建了一个小应用程序来检查使用espresso进行的测试。当在一个测试类中运行多个测试时,我观察到该活动正在暂停并为每个测试重新创建。我不认为这是正常的行为。Android - Espresso:每次测试重新创建活动
这里是我的测试类代码:
@RunWith(AndroidJUnit4.class)
@LargeTest
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class MyTestClass {
@Rule
public ActivityTestRule<MainActivity> mActivityRule = new ActivityTestRule(MainActivity.class);
@Before
public void beforeTest(){
// Called before each test
}
@After
public void afterTest(){
// Called after each test
}
@Test
public void a_clickButton() {
Log.d("robotarch", ">>>>>>> a_clickButton");
}
@Test
public void b_enterAndClick(){
Log.d("robotarch", ">>>>>>> b_enterAndClick");
}
}
在这旁边,我还增加了日志,我的所有活动的生命周期方法。
下面是输出的我得到的命令:
oncreate
onstart
onresume
onPostresume
>>>>>>> b_enterAndClick
onpause
onresume
onPostresume
onpause
oncreate
onstart
onresume
onPostresume
>>>>>>> a_clickButton
onStop
ondestroy
onpause
onStop
ondestroy
我查robotium相同的应用程序。它没有显示任何这样的行为。有人可以向我解释这种行为背后的原因吗?难道我做错了什么 ?
谢谢。所以,如果我想对整个应用程序进行功能测试,请检查UI流程,那么您建议的最佳方法是什么? –