The overloaded assertions introduced as part of #1638 broke Groovy's dynamic method dispatch. For example the following code yields the following exception:
assertEquals(2, new Integer(2), "some message")
groovy.lang.GroovyRuntimeException: Ambiguous method overloading for method org.junit.jupiter.api.Assertions#assertEquals.
Cannot resolve which method to invoke for [class java.lang.Integer, class java.lang.Integer, class java.lang.String] due to overlapping prototypes between:
[int, class java.lang.Integer, class java.lang.String]
[class java.lang.Integer, int, class java.lang.String]
Adding an overload that matches [class java.lang.Integer, class java.lang.Integer, class java.lang.String] exactly might solve the issue.
Let's see if @CompileStatic _solves_ the problem for Groovy. 😉
Team Decision:
@CompileStatic _improves_ the situation. We should therefore document that option in the User Guide.assertEquals(<wrapper type>, <wrapper type>, ...) variants to further improve Groovy's ability to select the appropriate overloaded method.Additional overloads also need to be added for assertNotEquals(<wrapper type>, <wrapper type>, ...).
@mmerdes I've pushed my experimentation branch to issues/1710-groovy-assertions-fixes.
@kreinhard found a similar issue using Kotlin here: https://github.com/micromata/projectforge/blob/PROJECTFORGE-3614-ReactJS/projectforge-jax-rs/src/test/kotlin/org/projectforge/rest/json/JsonValidatorTest.kt#L27
It compiles but produces the following at runtime:
java.lang.NoSuchMethodError: org.junit.jupiter.api.Assertions.assertEquals(ILjava/lang/Integer;)V
at org.projectforge.rest.json.JsonValidatorTest.parseJson(JsonValidatorTest.kt:27)
Sounds like a Kotlin bug...
@sormuras Please create a new issue. 🙂
Thanx, yesterday I’ve migrated all 179 Testclasses from TestNG to JUnit 5 and all problems disappeared. I guess, that Intellij got into trouble due to multiple test engines: TestNG, JUnit 4 and JUnit 5. There rest half a dozen of JUnit 4 test classes, but they work fine with maven as well as with Intellij now.
BTW: Excellent job, guys! I appreciate JUnit 5.
Am 11.04.2019 um 16:51 schrieb Christian Stein notifications@github.com:
@kreinhard https://github.com/kreinhard found a similar issue using Kotlin here: https://github.com/micromata/projectforge/blob/PROJECTFORGE-3614-ReactJS/projectforge-jax-rs/src/test/kotlin/org/projectforge/rest/json/JsonValidatorTest.kt#L27 https://github.com/micromata/projectforge/blob/PROJECTFORGE-3614-ReactJS/projectforge-jax-rs/src/test/kotlin/org/projectforge/rest/json/JsonValidatorTest.kt#L27
It compiles but produces the following at runtime:java.lang.NoSuchMethodError: org.junit.jupiter.api.Assertions.assertEquals(ILjava/lang/Integer;)V
at org.projectforge.rest.json.JsonValidatorTest.parseJson(JsonValidatorTest.kt:27)
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub https://github.com/junit-team/junit5/issues/1710#issuecomment-482147200, or mute the thread https://github.com/notifications/unsubscribe-auth/ABlzbkFEcdLAGRZ1Yk00QW5QcPb7mjnKks5vf0v2gaJpZM4Zf82u.
Most helpful comment
Thanx, yesterday I’ve migrated all 179 Testclasses from TestNG to JUnit 5 and all problems disappeared. I guess, that Intellij got into trouble due to multiple test engines: TestNG, JUnit 4 and JUnit 5. There rest half a dozen of JUnit 4 test classes, but they work fine with maven as well as with Intellij now.
BTW: Excellent job, guys! I appreciate JUnit 5.