Inline `whenever` to let Mockito's UnfinishedStubbing messages work

When Mockito detects unfinished stubbing, it will spit out an error containing:
```
Unfinished stubbing detected here:
-> at com.nhaarman.mockitokotlin2.OngoingStubbingKt.whenever(OngoingStubbing.kt:42)
```

This is not useful in helping users track down unfinished stubbing.  Instead, we inline `whenever`
to make it read as:
```
Unfinished stubbing detected here:
-> at com.me.MyTest.testMyThing(MyTest.kt:785)
```
2 files changed
tree: dfcb6821f6fd9757367aad85ee21a78ce630fcd9
  1. .github/
  2. .idea/
  3. gradle/
  4. mockito-kotlin/
  5. ops/
  6. tests/
  7. .gitignore
  8. .travis.yml
  9. build.gradle
  10. gradle.properties
  11. gradlew
  12. gradlew.bat
  13. LICENSE
  14. publishing.gradle
  15. README.md
  16. RELEASING.md
  17. settings.gradle
README.md

Mockito-Kotlin

Download

A small library that provides helper functions to work with Mockito in Kotlin.

Install

Mockito-Kotlin is available on Maven Central and JCenter. For Gradle users, add the following to your build.gradle, replacing x.x.x with the latest version:

testCompile "com.nhaarman.mockitokotlin2:mockito-kotlin:x.x.x"

Example

A test using Mockito-Kotlin typically looks like the following:

@Test
fun doAction_doesSomething(){ 
  /* Given */
  val mock = mock<MyClass> {
    on { getText() } doReturn "text"
  }
  val classUnderTest = ClassUnderTest(mock)
  
  /* When */
  classUnderTest.doAction()
  
  /* Then */
  verify(mock).doSomething(any())
}

For more info and samples, see the Wiki.