Skip to content

Instantly share code, notes, and snippets.

@markchristopherng
Created February 19, 2020 03:21
Show Gist options
  • Save markchristopherng/ddce4d10cd875d979efbf35ce073f475 to your computer and use it in GitHub Desktop.
Save markchristopherng/ddce4d10cd875d979efbf35ce073f475 to your computer and use it in GitHub Desktop.
@RunWith(MockitoJUnitRunner::class)
class GreetingServiceMockTest {
@get:Rule
var toothPickRule = ToothPickRule(this, "scope")
@Inject
lateinit var greetingService: GreetingService
@Mock
lateinit var timeService: TimeService
@Before
fun setup() = toothPickRule.scope.installModules(toothpickModule).inject(this)
@Test
fun testGreetingInTheMorning() {
whenever(timeService.getHourOfDay()).thenReturn(9)
assertEquals("Good morning, welcome to Toothpick", greetingService.greetings())
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment