You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am facing a very interesting question when using Spock and this extension with Kotlin classes. If I use the @Collaborator annotation in my spec to mock a collaborator & stub one of the response of the said collaborator, I can see that the stubbed method never gets used. The framework makes a call to a real instance instead of the mocks. If I convert my collaborator to Java, it works as expected. Allow me to explain the issue with a code snippet
And here is the result of the test, which throw a NPE coz the real instance gets called instead of the mocks!
java.lang.NullPointerException
at com.johnlewis.order.manage.PaymentMethodBuilder.display(PaymentMethodBuilder.kt:6)
at com.johnlewis.order.manage.CancelItemBuilder.display(CancelItemBuilder.kt:6)
at com.johnlewis.order.manage.CancelItemBuilderSpec.test this crap(CancelItemBuilder.groovy:18)
The text was updated successfully, but these errors were encountered:
Hello,
I am facing a very interesting question when using Spock and this extension with Kotlin classes. If I use the @Collaborator annotation in my spec to mock a collaborator & stub one of the response of the said collaborator, I can see that the stubbed method never gets used. The framework makes a call to a real instance instead of the mocks. If I convert my collaborator to Java, it works as expected. Allow me to explain the issue with a code snippet
And here is the test
And here is the result of the test, which throw a NPE coz the real instance gets called instead of the mocks!
The text was updated successfully, but these errors were encountered: