Testing that button starts an Activity with Robolectric

后端 未结 8 926
眼角桃花
眼角桃花 2020-12-24 11:25

Hi I have the following code:

@RunWith(Test9Runner.class)
public class MainActivityTest 
{
    private MainActivity activity;
    private Button pressMeButto         


        
8条回答
  •  时光取名叫无心
    2020-12-24 11:44

    Updating this for 3.1.2 as the answers above did not work for me:-

        loginButton.callOnClick();
    
        Intent startedIntent = shadowOf(activity).getNextStartedActivity();
        ShadowIntent shadowIntent = shadowOf(startedIntent);
        assertEquals(NextActivity.class, shadowIntent.getIntentClass()); 
    

提交回复
热议问题