Mock KRule
A simple JUnit 4 rule which handles the setting up and tearing down of mock objects using the MockK or RelaxedMockK annotations at the beginning and end of each test respectively - without needing to manually call unmockkAll or MockKAnnotations.init.
Example:
class ExampleTest {
@get:Rule
val mockkRule = MockKRule(this)
@MockK
private lateinit var car: Car
@Test
fun something() {
every { car.drive() } just runs
...
}
}
Content copied to clipboard