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
Broken mocking of sealed classes after upgrading to 1.13.2 #1015
Comments
1.13.3 has the same issue (at least, with sealed interfaces)... |
@stuebingerb is behaviour described in this issue is expected result of #916 ? |
I would have to look into it but as a first response I think it is safe to assume that this is a result of my lacking knowledge of mockk as well as the issues I had with actually testing my changes, i.e. unexpected. And IMHO running code should not break with a new bugfix version. |
A small example: import io.mockk.impl.annotations.RelaxedMockK
import io.mockk.junit5.MockKExtension
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.extension.ExtendWith
/**
* @author tk35c
* @since 23/01/2023
**/
@ExtendWith(MockKExtension::class)
class TestBrokenMockSealedInterface {
@RelaxedMockK
private lateinit var myInterface: MyInterface
@Test
fun `should not print`() {
myInterface.foo()
}
}
sealed interface MyInterface {
fun foo()
}
class MyClass: MyInterface {
override fun foo() {
error("Should not come here")
}
} The real method of |
Seems to be fixed in 1.13.3 |
I still see this issue 1.13.5 |
Same issue in 1.13.3 and 1.13.8 it's seems to works on mac but not on linux (we use same jvm version). We try with openjdk and oracle jdk (17.0.0) |
Prerequisites
After upgrading mockk dependency from 1.13.1 to 1.13.2 many tests started to fail in our project. It seems to be related to #916.
The problem is related to sealed classes or interfaces with child objects or data classes.
To make it easier to understand, I've prepared reproduction project:
https://github.com/vudzkostek/MockKReproduce
There are two different crashes in my sample project, both related to version 1.13.2. When downgraded to 1.13.1 everything passes.
I am not entirely sure if these failing tests are intended result of #916 or real issue that should be fixed in next release.
Stack traces
The text was updated successfully, but these errors were encountered: