Open bodiam opened 7 years ago
i needed to add also the AddressService to be loaded by kotlintestrunner I assume the default JVM class loader, for some reasons, loaded AddressService first and with it a different version of GoogleService. Sent PR with fix
@OpenedClasses([GoogleService, AddressService])
Hi Danny,
Thanks for checking it out. Interesting, it's not what I expected. I thought that I only needed to specify the class which I want to be opened, and I didn't see the need to open the address service too.
Thanks, Erik
On 18 Dec 2016, at 02:41, Danny Preussler notifications@github.com wrote:
@OpenedClasses([GoogleService, AddressService])
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.
Your are right, it shouldn't be like this. See our examples. I'll keep this open and will check if the same would happen when writing the test in kotlin. Something is different with yours then with our examples.
For now what you could do is use @OpenedPackages and add your root package there. Might only effect performance a bit.
yes it was as I assumed, get more error when doing with kotlin:
java.lang.LinkageError: loader constraint violation: when resolving method "de.jodamob.kotlin.testrunner.anotherpackage.AddressService.
and it wont happen if both classes are in same package. Will look more into it
Interesting, and thanks for the update. It's good to hear that both groovy and Kotlin are having the same, or a similar problem here.
On 19 Dec 2016, at 00:31, Danny Preussler notifications@github.com wrote:
yes it was as I assumed, get more error when doing with kotlin:
java.lang.LinkageError: loader constraint violation: when resolving method "de.jodamob.kotlin.testrunner.anotherpackage.AddressService.(Lde/jodamob/kotlin/testrunner/sample/GoogleService;)V" the class loader (instance of de/jodamob/kotlin/testrunner/NoMoreFinalsClassLoader) of the current class, de/jodamob/kotlin/testrunner/tests/TestWithTwoClasses, and the class loader (instance of sun/misc/Launcher$AppClassLoader) for the method's defining class, de/jodamob/kotlin/testrunner/anotherpackage/AddressService, have different Class objects for the type de/jodamob/kotlin/testrunner/sample/GoogleService used in the signature
and it wont happen if both classes are in same package. Will look more into it
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.
I'm trying to mock out a Kotlin service which acts as a collaborator for another service. This is failing, resulting in the following error:
I've created a small project here to reproduce the error: https://github.com/bodiam/kotlin-spock-issue