kotlin-testrunner
kotlin-testrunner copied to clipboard
AndroidTest Test Class NotFoundException
I managed to hook into AndroidJUnitRunner
but I'm getting a NotFoundException
when the NoMoreFinalClassLoader
tries to create a CtClass
for my test class:
javassist.NotFoundException: com.app.LaunchActivityTest
at javassist.ClassPool.get(ClassPool.java:452)
at de.jodamob.kotlin.testrunner.NoMoreFinalsClassLoader.process(NoMoreFinalsClassLoader.kt:33)
at de.jodamob.kotlin.testrunner.NoMoreFinalsClassLoader.loadClass(NoMoreFinalsClassLoader.kt:24)
at de.jodamob.kotlin.testrunner.ClassOpeningClassLoaderConfiguratorKt.configureClassOpeningClassLoader(ClassOpeningClassLoaderConfigurator.kt:8)
at android.support.test.internal.runner.MyTestRequestBuilder.build(MyTestRequestBuilder.java:730)
at com.app.MyAndroidJUnitRunner.buildRequest(MyAndroidJUnitRunner.java:194)
at com.app.MyAndroidJUnitRunner.onStart(MyAndroidJUnitRunner.java:101)
at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1932)
not sure this will work with AndroidRunner. Have my doubts but give it a try.
I checked, there is a javassist version for android https://github.com/crimsonwoods/javassist-android
Maybe you can try to exclude the ones we use: compile("de.jodamob.kotlin:kotlin-runner-junit4:0.3.1") { exclude module: 'javassist' }
and then include the above one instead.
I had the same problem. As I understood it's not related to Android, but to test run configuration and classpath. For me test class was loaded with another class loader (URLClassLoader
), different than parent of NoMoreFinalsClassLoader
, which is AppClassLoader
, gotten by ClassLoader#getSystemClassLoader
.
My IntelliJ IDEA's run configuration's Shorten command line property was classpath file, which I changed to JAR manifest and problem was fixed.
If this could be fixed by kotlin-testrunner library, that'd be neat.
BTW, I experienced the problem using kotlin-runner-spock
.