Skip to content

Instantly share code, notes, and snippets.

@markchristopherng
Created February 19, 2020 00:23
Show Gist options
  • Save markchristopherng/d5a6b9adc187c1b4f4f6d2355863f561 to your computer and use it in GitHub Desktop.
Save markchristopherng/d5a6b9adc187c1b4f4f6d2355863f561 to your computer and use it in GitHub Desktop.
class GreetingServiceMockTest : KoinTest {
private val greetingService: GreetingService by inject()
@Test
fun testGreetingInTheMorning() {
startKoin { modules(koinModule) }
declareMock<TimeService> {
given(this.getHourOfDay()).willReturn(9)
}
assertEquals("Good morning, welcome to Koin", greetingService.greetings())
stopKoin()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment