8

在Android Studio中,當我調試儀器測試時,測試不會停在任何斷點上。調試單元測試的作品。我有一個簡單的儀表測試,如果僅顯示用戶名檢查的EditText:如何在Android Studio中調試儀器測試?

@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" 

如何調試儀器測試?我使用濃咖啡,Mockito和匕首2.

回答

6

你可以通過幾種方法解決這個Tomask。

如果您從命令行調用測試,則可以在測試的配置中傳遞-e debug true選項。

否則,更簡單地說,你應該從機器人工作室開始您的測試時,選擇調試,而不是運行。如果你點擊運行來測試android studio,選項-e debug false會被設置,並且測試不會停止在斷點處執行。

希望這會有所幫助!

相關問題