ron
01/17/2018, 8:06 PMron
01/17/2018, 8:06 PMron
01/17/2018, 8:06 PMron
01/17/2018, 8:07 PMpoohbar
01/17/2018, 8:08 PMclass MyTest {
val dependency: ConcreteDependency = mockk()
val service = ServiceUnderTest(dependency)
@Test
fun `should test something`() {
every { dependency.foo(any()) } returns "some result"
val result = service.methodUnderTest("param")
verify { dependency.bar() }
result shouldEqual "some result"
}
}
poohbar
01/17/2018, 8:09 PMConcreteDependency
was an interface it would work exactly the same except in my sources I would have to have duplicated signatures for Dependency
and DependencyImpl
ron
01/17/2018, 8:10 PMpoohbar
01/17/2018, 8:10 PMron
01/17/2018, 8:11 PMpoohbar
01/17/2018, 8:11 PMConcreteDependency
in this case would probably be a repository.. that way I can unit test without spinning up the dbpoohbar
01/17/2018, 8:12 PMEmailService
since I dont want the test to send out email, I just use a mock and do no-op on sendEmail(..)
methodsron
01/17/2018, 8:13 PMron
01/17/2018, 8:13 PMpoohbar
01/17/2018, 8:15 PMIsaac
01/17/2018, 8:59 PMcarlw
01/17/2018, 9:17 PMIsaac
01/17/2018, 9:24 PMIsaac
01/17/2018, 9:24 PMIsaac
01/17/2018, 9:25 PMIsaac
01/17/2018, 9:27 PMron
01/17/2018, 9:42 PMpike
01/17/2018, 10:58 PMCarlton Whitehead
01/18/2018, 12:44 AMby inject()
) is being retained between tests. What's the best way to reset that?Carlton Whitehead
01/18/2018, 12:48 AMCarlton Whitehead
01/18/2018, 1:01 AMCarlton Whitehead
01/18/2018, 1:03 AMamanda.hinchman-dominguez
01/18/2018, 1:08 AMCarlton Whitehead
01/18/2018, 1:10 AMstop()
is a callback given by TestFX's ApplicationTestamanda.hinchman-dominguez
01/18/2018, 1:10 AM