作者热门文章
- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
在 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/
我是一名优秀的程序员,十分优秀!