mockito / mockito-kotlin

Using Mockito with Kotlin
MIT License
3.09k stars 198 forks source link

Wrong return value from doAnswer #487

Open victorspivak opened 11 months ago

victorspivak commented 11 months 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 9 months ago

seam issue, any updates?