mockito / mockito-kotlin

Using Mockito with Kotlin
MIT License
3.11k stars 201 forks source link

Add support for per-mock strictness #325

Closed thevoiceless closed 2 years ago

thevoiceless commented 5 years ago

See https://github.com/mockito/mockito/pull/1272

Mockito 2.20.1 added support for per-mock/stubbing strictness. It looks like the most straightforward option would be passing an additional argument to withSettings().

thevoiceless commented 5 years ago

For anyone wanting to use this in the meantime: You simply replace whenever with Mockito.lenient().`when`, orMockito.mock(Foo::class.java, withSettings().lenient()) to make the entire mock lenient.

thevoiceless commented 5 years ago

Actually, it looks like this may have been fixed 10 days ago with https://github.com/nhaarman/mockito-kotlin/pull/353

It allows passing the lenient parameter to mock(...) but does not add a lenient version of whenever