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)));
}