Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

java.lang.AbstractMethodError #19

Closed
davideas opened this issue Oct 7, 2017 · 5 comments
Closed

java.lang.AbstractMethodError #19

davideas opened this issue Oct 7, 2017 · 5 comments

Comments

@davideas
Copy link

davideas commented Oct 7, 2017

In Android Studio 2.3.3, applying:

apply plugin: 'com.android.library'
apply plugin: 'de.mannodermaus.android-junit5'

junitPlatform {
    jupiterVersion "5.0.1"
    platformVersion "1.0.1"
}

dependencies {
    ...
    testCompile junit5()
    testCompile "de.mannodermaus.gradle.plugins:android-junit5-embedded-runtime:1.0.0-RC3-rev1"
}

I get this exception:

Exception in thread "main" java.lang.AbstractMethodError:
com.intellij.junit5.JUnit5IdeaTestRunner.setStreams(Ljava/lang/Object;Ljava/lang/Object;I)V
	at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:261)
	at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:84)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)
@mannodermaus
Copy link
Owner

mannodermaus commented Oct 7, 2017

I can reproduce the issue here, and it's tied to the android-junit5-embedded-runtime dependency. It seems like overriding the JUnit 5 Runtime causes an incompatibility with the way Android Studio 2.x is hooking into the launch process, most likely due to renamed internal APIs.

You can see that the method doesn't even exist anymore inside IdeaTestRunner.java. I guess it would be necessary to override more of the standard JUnit runtime classes to make this work, however that might break other internals of AS (the embedded runtime is a dirty hack as it is already…).

I'm afraid that you are going to need to run your unit tests from Gradle directly (./gradlew junitPlatformTest works just fine), at least for the time being, or switch to the AS 3.x Beta. I'll extend the info in the README to explicitly state this incompatibility though.

@mannodermaus
Copy link
Owner

Actually, let me keep this open & experiment a little with including more IntelliJ JARs into the embedded runtime. I'll keep you posted! Might be a few days, though.

@mannodermaus mannodermaus reopened this Oct 7, 2017
@davideas
Copy link
Author

davideas commented Oct 7, 2017

@mannodermaus, thanks! Currently I can't migrate to AS 3 beta for this project until AS is in final version. But it will be soon as we know Android team is working hard. So, maybe just try, but don't spend so much time on it. I will stick with JUnit4 for a while.

@davideas
Copy link
Author

davideas commented Oct 7, 2017

@mannodermaus, I tried with AS 3 beta7, but the embedded-runtime library is still necessary. However, there it works.

@mannodermaus
Copy link
Owner

Yes, even the latest Beta of Android Studio 3 isn't "up-to-date enough" with IntelliJ's master branch to fix the incompatibility issue present in older versions, so the embedded-runtime is required there as well. As for Android Studio 2, I haven't managed to replace the JUnitStarter responsible for accessing the removed setStreams method in the same way, so I'm afraid that launching JUnit 5 tests from the IDE directly isn't going to work with AS 2. I'll update the Readme and attach a notice there. Again, running the Gradle task directly still works, of course.

Thanks for making me aware of this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants