Skip to content

Instantly share code, notes, and snippets.

@kikuchy
Created May 25, 2018 06:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kikuchy/de7344dd9c9577cd714f344a61c2c60c to your computer and use it in GitHub Desktop.
Save kikuchy/de7344dd9c9577cd714f344a61c2c60c to your computer and use it in GitHub Desktop.
// app/src/test/(java|kotlin))/(package名)/ExampleUnitTest.kt
@RunWith(AndroidJUnit4::class)
class ExampleUnitTest {
@Test
fun useAppContext() {
val context = InstrumentationRegistry.getTargetContext()
val sp = context.getSharedPreferences("hoge", Context.MODE_PRIVATE)
sp.edit().putBoolean("hoge", true).apply()
assertTrue(sp.getBoolean("hoge", false))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment