Skip to content

Instantly share code, notes, and snippets.

@markchristopherng
Last active February 21, 2020 00:08
Show Gist options
  • Save markchristopherng/945ad4c7e5c3b9cbbce2a48acde0101f to your computer and use it in GitHub Desktop.
Save markchristopherng/945ad4c7e5c3b9cbbce2a48acde0101f to your computer and use it in GitHub Desktop.
@RunWith(MockitoJUnitRunner::class)
class GreetingServiceTest {
private lateinit var greetingService: GreetingService
@Mock
lateinit var timeService: TimeService
@Before
fun setup() {
greetingService = GreetingServiceImpl(MessageData("welcome to Dagger"), timeService)
}
@Test
fun testGreetingInTheMorning() {
whenever(timeService.getHourOfDay()).thenReturn(9)
assertEquals("Good morning, welcome to Dagger", greetingService.greetings())
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment