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
Bug: mock that return set of Mocks fails #221
Comments
Looks seriius, thanks for the report |
Isn't the same issue as #201 ? Currently MockK doesn't support creating mocks during stubbing. The following version passes, since the mocks are created before the stubbing. @Test
fun prepare() {
val foo = mockk<Foo>()
val set = setOf(mockk<Task>(), mockk<Task>())
every { foo.getTasks() } returns set
} P.S: While waiting for #201, another alternative is to use @Test
fun prepare() {
val foo = mockk<Foo>()
every { foo.getTasks() } answers { setOf(mockk(), mockk()) }
} |
@jcornaz missed this point. It might be, but I have doubts. There we have stubbing inside of unfinished stubbing and here just set of two mockks. Require a check, will check later |
Released 1.9.1. Please try it out and close the ticket if everything is fine |
I've tested. It's working as expected. Thank you. |
Description
I trying to mock the following interfaces:
Test example:
Special for the test that mock returns set of mocks again. HashMap invokes then hashCode method of the mock object.
Expected Behavior
The test should pass
Current Behavior
The test fails
Failure Information (for bugs)
Stack trace
Minimal reproducible code (the gist of this issue)
The text was updated successfully, but these errors were encountered: