gpt4 book ai didi

android - 如何在 Android Studio 中调试仪器测试?

转载 作者:塔克拉玛干 更新时间:2023-11-01 21:25:42 24 4
gpt4 key购买 nike

在 Android Studio 中调试仪器测试时,测试不会在任何断点处停止。调试单元测试有效。我有一个简单的仪器测试,只检查是否显示用户名 edittext:

@RunWith(AndroidJUnit4.class)
public class LogonActivityTest {

@Rule
public ActivityTestRule<LogOnActivity> mActivityRule = new ActivityTestRule<>(LogOnActivity.class, true, false);

@Before
public void setUp() throws Exception {
mActivityRule.launchActivity(new Intent()); // breakpoint here
}

@Test
public void testSimple() throws Exception {
onView(withId(R.id.act_logon_et_username)).check(matches(isDisplayed())); // breakpoint here
}
}

build.gradle中我已经正确设置了

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

如何调试插桩测试?我正在使用 Espresso、Mockito 和 Dagger 2。

最佳答案

您可以通过多种方式解决 Tomask。

如果您从命令行调用测试,则可以在测试配置中传递选项 -e debug true。

否则,更简单地说,当从 android studio 开始测试时,您应该选择 Debug 而不是 Run。如果您从 android studio 单击 Run 进行测试,则会设置选项 -e debug false 并且测试不会在断点处停止执行。

希望这对您有所帮助!

关于android - 如何在 Android Studio 中调试仪器测试?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36919407/

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