Skip to content

Instantly share code, notes, and snippets.

@maskaravivek
Created May 17, 2018 18:56
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 maskaravivek/a2a72c014c6340ddbba7093f13aa4a77 to your computer and use it in GitHub Desktop.
Save maskaravivek/a2a72c014c6340ddbba7093f13aa4a77 to your computer and use it in GitHub Desktop.
class UserServiceTest {
@Mock internal var context: Context? = null
@InjectMocks internal var userService: UserService? = null
@Before
fun setup() {
MockitoAnnotations.initMocks(this)
}
@Test
fun displayUserName() {
doReturn("Hello %s!").`when`(context)!!.getString(any(Int::class.java))
val displayUserName = userService!!.displayUserName("Test")
assertEquals(displayUserName, "Hello Test!")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment