Skip to content

Commit 3131b2c

Browse files
add mockk
1 parent b638f09 commit 3131b2c

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,22 @@ fun isNotDigit(c: Char) = c !in '0'..'9'
195195

196196
Example: [09-inoperation.kt](./examples/09-inoperation.kt)
197197

198+
## Mock
199+
200+
We can use [Mockito](https://github.com/mockito/mockito), but the best lib to mock using kolint is [Mockk](https://github.com/mockk/mockk)
201+
202+
``` kotlin
203+
val car = mockk<Car>()
204+
205+
every { car.drive(Direction.NORTH) } returns Outcome.OK
206+
207+
car.drive(Direction.NORTH) // returns OK
208+
209+
verify { car.drive(Direction.NORTH) }
210+
211+
confirmVerified(car)
212+
```
213+
198214
## References
199215

200216
- [Learn the Kotlin programming language](https://developer.android.com/kotlin/learn?gclsrc=aw.ds&gclid=CjwKCAjw9e6SBhB2EiwA5myr9tk-mZhoAytl5-3nJeQ0lgYnyIGcs5GFh9-aN1tDvkwvcrFEAJZdLhoC0lAQAvD_BwE)

0 commit comments

Comments
 (0)