mockito / mockito-kotlin

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

Wrong return value from doAnswer #487

Open victorspivak opened 1 year ago

victorspivak commented 1 year ago

Mocking a method that returns a Result does not work.Instead of Result it returns Result<Result>. There is a simple example to reproduce it:

import org.amshove.kluent.shouldBeEqualTo import org.junit.jupiter.api.Test import org.mockito.kotlin.* import org.mockito.kotlin.any

// User: victor Date: 7/17/23 Time: 1:35 PM

interface Foo { fun foo(name: String): Result } class Test111 { @Test fun test() { val myMock = mock() { on { foo(any()) } doAnswer { Result.success(true) } }

    myMock.foo("test").toString() shouldBeEqualTo "Success(true)"
}

}

I got the following error:

Expected: <Success(true)> but was: <Success(Success(true))>

morkovkin commented 1 year ago

seam issue, any updates?