mockito-kotlin
mockito-kotlin copied to clipboard
Using Mockito with Kotlin
I understood that it will be linked to the mockito releases. Was I wrong?
```kotlin class UnderTest { fun doStuff(string1: String, string2: String = "hello world") = "do stuff" } @Test fun testIt() { val underTest = mock(UnderTest::class.java) whenever(underTest.doStuff(anyString())).thenReturn("stuff done") } ``` InvalidUseOfMatchersException "This...
Thank you for submitting a pull request! But first: - [x] Can you back your code up with tests? - [x] Keep your commits clean: [squash your commits if necessary](https://git-scm.com/book/en/v2/Git-Tools-Rewriting-History).
See #372 for reference I believe `String` values in mocks should return `""` by default. It is a historically 'special' type which has always had some special 'primitive-like' privileges. I...
Hi, After switching kotlin's api/language from 1.4 to 1.5, the following code: ``` @Test fun test() { val deferredSupplier = spy(Supplier { Flux.empty() }) Flux.defer(deferredSupplier).blockLast() verify(deferredSupplier, times(1)).get() } ``` fails...
Another bug has emerged while working on #441 The following two methods have identical bodies, the only difference is in test methods' names, the second one contains a space ```...
I've asked the question here and there's a code example: https://stackoverflow.com/questions/68933185/injectmocks-doesnt-work-with-kotlin-constructor-arguments-with-default-values I think when Mockito tries to inspect the constructor to match it to declared mocks, it finds more parameters...
Good Afternoon, When I try to compile my project with the dependency it gives me the following error: Could not download mockito-kotlin-2.2.0.jar (com.nhaarman.mockitokotlin2:mockito-kotlin:2.2.0) > Could not get resource 'https://jcenter.bintray.com/com/nhaarman/mockitokotlin2/mockito-kotlin/2.2.0/mockito-kotlin-2.2.0.jar'. >...
Run this test code: ```kotlin val suspendFunction : suspend () -> Unit = mock() runBlocking { suspendFunction.invoke() } runBlocking { verify(suspendFunction).invoke() } ``` It should succeed (function was invoked, so...
```kotlin @get:Rule val dispatcherRule = CoroutineTestRule() private val validator: Validator = mock() private val viewModel = MainViewModel(validator) @Test fun `test user data retrieved successfully`() = dispatcherRule.runBlockingTest { viewModel.getData() } ```...