Created
May 17, 2018 18:56
-
-
Save maskaravivek/a2a72c014c6340ddbba7093f13aa4a77 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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