I am new to unit testing in Android and my attempt is to assertTrue that the data is successfully passed to a method and saved in SharedPreferences. This is my test so far:
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 method:
public void saveAuth(Auth auth) {
editor.putString("USER_AUTH", new Gson().toJson(auth));
editor.commit();
}
What would the assertion look like for this?