Я новичок в модульном тестировании в Android, и моя попытка состоит в том, чтобы assertTrue
данные были успешно переданы методу и сохранены в SharedPreferences
. Это мой тест на данный момент:
public class AuthTest {
Authorization authorization = new Authorization();
@Before
public void init() {
MockitoAnnotations.initMocks(this);
}
@Test
public void test_IfAuthIsSaved() {
//test if the auth object is saved in the auth object is saved as a..
//..json string in Shared preferences
Auth auth = mock(Auth.class);
authorization.saveAuth(auth);
//test if the auth is received and saved to sharedpreferences
}
}
метод saveAuth:
public void saveAuth(Auth auth) {
editor.putString("USER_AUTH", new Gson().toJson(auth));
editor.commit();
}
Как будет выглядеть утверждение для этого?