Spy verification doesn't work for methods called from constructor:
class TestClass {
init { test() }
fun test() {}
}
...
val spyed = spyk(TestClass())
...
verify { spyed.test() }
I'm kinda novice at testing but I do understand one could create another constructor for testing purpose without some kind of setup method call. I just wonder, is this feature out of scope or planned for future?
There is demand I would say for constrctor mocking, eventually it will be implemented. No exact plans yet
I would say that having whenNew => thenReturn will be really great tool for some edge cases 鈾ワ笍 Great that you have it in your future plans! 馃槏
This feature was implemented some time ago, but I didn't want to close the ticket as it is implemented different way. It is still not possible to mock calls inside of constructor, but rather possible after.
I'm closing it now
Most helpful comment
There is demand I would say for constrctor mocking, eventually it will be implemented. No exact plans yet