Taste { @SuppressLint("CommitPrefEdits") void save(SharedPreferences.Editor editor, boolean commit) { if (!commit || Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) editor.apply(); else editor.commit(); } Taste(SharedPreferences sp, String key, String[] defaultValue);   }
@Test public void testSave() throws Exception { dummyTaste.save(editor, true); verify(editor).commit(); }