kotlin-testrunner
kotlin-testrunner copied to clipboard
mockito non-final classes error
Mockito still complains about kotlin classes even if I opens up the whole package.
I trace the code to NoMoreFinalsClassLoader.process
, for the same className when the first time this method is called it does go into removeFinal
, and it runs fine. however, when the second time this method is called with the same className, because the final is removed, it goes to defaultClass.toClass(this) as Class<T>
Then in bytebuddy invoked by Mockito this gets thrown:
javassist.CannotCompileException: by java.lang.LinkageError: loader (instance of de/jodamob/kotlin/testrunner/NoMoreFinalsClassLoader): attempted duplicate class definition for name: "my/className"
In the NoMoreFinalsClassLoader, should loaded classes be cached?
Having the same problem.
@tasomaniac mockito can mock final classes now, see this
I've been struggling with that a lot recently. We have PowerMockito in our project and right now it is impossible to remove it. Unfortunately we couldn't make mockito Inline mock maker to work when we have PowerMockito in place. It actually works in some Java sdks in command line. Never worked with Android Studio.
you can try my commit to see if it works with your project?
I saw that but I didn't have time to check it out and build it myself. Do you have a jar or maven coordinates? Then it would be super easy to try :) Thanks.