Search in sources :

Example 1 with BoundBox

use of org.boundbox.BoundBox in project Quality-Tools-for-Android by stephanenicolas.

the class MyActivityTest method shouldUseCustomComputerUsingMockitoAndBoundBox.

@BoundBox(boundClass = HelloAndroidActivity.class, maxSuperClass = FragmentActivity.class)
@Test
public void shouldUseCustomComputerUsingMockitoAndBoundBox() throws Exception {
    final int EXPECTED_RESULT = 1;
    // given
    HelloAndroidActivity activityUnderTest = Robolectric.buildActivity(HelloAndroidActivity.class).create().get();
    BoundBoxOfHelloAndroidActivity boundBoxOfHelloAndroidActivity = new BoundBoxOfHelloAndroidActivity(activityUnderTest);
    Computer mockComputer = Mockito.mock(Computer.class);
    Mockito.when(mockComputer.getResult()).thenReturn(EXPECTED_RESULT);
    boundBoxOfHelloAndroidActivity.setComputer(mockComputer);
    // when
    boundBoxOfHelloAndroidActivity.boundBox_getButton().performClick();
    // then
    Mockito.verify(mockComputer, Mockito.times(1)).getResult();
    String textViewHelloString = boundBoxOfHelloAndroidActivity.boundBox_getTextView().getText().toString();
    assertThat(textViewHelloString, equalTo(String.valueOf(EXPECTED_RESULT)));
}
Also used : Computer(com.octo.android.sample.model.Computer) Test(org.junit.Test) BoundBox(org.boundbox.BoundBox)

Aggregations

Computer (com.octo.android.sample.model.Computer)1 BoundBox (org.boundbox.BoundBox)1 Test (org.junit.Test)1