Hey everyone, I'm wondering if mocking a non-mocke...
# mockk
c
Hey everyone, I'm wondering if mocking a non-mocked instance is a feature or a bug? It appears the following works:
Copy code
val notAMock = NotAMock() // some sample class, it's not a mock
every { notAMock.getAString() } returns "This should not work, right?"
assertEquals("This should not work, right?", notAMock.getAString()) // passes
This is a simplified example of code I was reviewing for an internal project at work. In that case
notAMock
was a class under test that should not be mocked, it was easy to overlook on the first pass but I saw the behavior repeated in a few tests which is how I caught it. I would expect some exception to be thrown if a real object is being mocked.