New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
1.12.5 every
fails when kotlin.time.Duration
should be returned
#869
Comments
Should be fixed by #872 |
It was fixed with recent version |
I still have this error in a similar setup with mockk |
@naivekook Could you provide a simple test to reproduce the error? |
If the Foo.kt
Bar.kt
FooTest.kt
By the way, if in my test I use a mock like this, it still doesn't work (same class cast error):
Github project: https://github.com/NinoDLC/MockK_Duration_Bug |
The issue is still relevant (version 1.13.4). Example of code: "DelayMode function should invoke" {
val exception = RuntimeException("test")
val mockCall: () -> String = mockk()
every { mockCall() } throws exception andThen "test"
val delayFunc: (RetryAttemptInput) -> kotlin.time.Duration = mockk()
every { delayFunc.invoke(any()) }.returns(1.milliseconds) // HERE THE EXCEPTION
} Exception: |
@Raibaz are there any plans to fix the issue? |
Still getting the exception when using Duration? (nullable Duration). @Raibaz can we reopen this issue? Or maybe create a new one for nullable Duration? |
I'd rather open a new one for the nullable Duration |
Very annoying issue. Because of this bug i have to use mockito as a workaround for mocking interfaces with methods which return value classes, Duration for example. For other cases i'm using mockk. |
@Raibaz could you reopen the issue? Or should we create a new one? |
See above, I'd rather have a new one. |
Same happened when I verifying value in match expression in coEvery: awsS3Client.getFileTemporaryUrl(
bucket = match { it shouldBe "imagesS3Bucket"; true },
key = match { it shouldBe imageId; true },
validFor = match { it shouldBe 1.hours; true }
) validFor is Kotlin Duration |
Looks like this issue has regressed in v1.13.10.
|
Prerequisites
Please answer the following questions for yourself before submitting an issue.
Expected Behavior
Calling the
every
method succeeds and returns the correct an object ofkotlin.time.Duration
when calledCurrent Behavior
The method calls fails and throws a java.lang.ClassCastException
Failure Information (for bugs)
Steps to Reproduce
In mockk 1.12.4 I was able to use the
every
mocking method and return a value on a method call from a method that returnskotlin.time.Duration
1.12.5 seems to have broken this and tries to cast the
kotlin.time.Duration
into ajava.lang.Long
unsuccessfully.Code below.
Context
Please provide any relevant information about your setup. This is important in case the issue is not reproducible except for under certain conditions.
Stack trace
Minimal reproducible code (the gist of this issue)
The text was updated successfully, but these errors were encountered: