@Test publicvoidreadStringFromContext_LocalizedString(){ // Given a mocked Context injected into the object under test... when(mMockContext.getString(R.string.hello_word)) .thenReturn(FAKE_STRING); ClassUnderTest myObjectUnderTest = new ClassUnderTest(mMockContext);
// ...when the string is returned from the object under test... String result = myObjectUnderTest.getHelloWorldString();
// ...then the result should be the expected one. assertThat(result, is(FAKE_STRING)); } }
// Verify that the received data is correct. assertThat(createdFromParcelData.size(), is(1)); assertThat(createdFromParcelData.get(0).first, is(TEST_STRING)); assertThat(createdFromParcelData.get(0).second, is(TEST_LONG)); } }