ota4j-team / opentest4j

Open Test Alliance for the JVM
Apache License 2.0
284 stars 37 forks source link

java.lang.NoSuchMethodError: org.opentest4j.ValueWrapper.create(java.lang.Object, java.lang.String) #66

Closed vprudnikov closed 4 years ago

vprudnikov commented 4 years ago

Hi,

I get a strange NoSuchMethodError exception when running my spock tests (spock version 2.0-M3-groovy-3.0). I have a maven project and I can confirm that I'm using opentest4j 1.2.0

I can't get a descriptive message in console when my test should fail. Instead, I get this:

java.lang.NoSuchMethodError: 'org.opentest4j.ValueWrapper org.opentest4j.ValueWrapper.create(java.lang.Object, java.lang.String)'

    at org.spockframework.runtime.MasterRunSupervisor.convertToComparisonFailure(MasterRunSupervisor.java:92)
    at org.spockframework.runtime.MasterRunSupervisor.transform(MasterRunSupervisor.java:67)
    at org.spockframework.runtime.MasterRunSupervisor.error(MasterRunSupervisor.java:46)
    at org.spockframework.runtime.MasterRunSupervisor.handleMultipleFailures(MasterRunSupervisor.java:61)
    at org.spockframework.runtime.MasterRunSupervisor.error(MasterRunSupervisor.java:42)

I went to source code and I saw that opentest4j contains 2 'create' methods. One of them takes Object, another one takes Object and String. However, when I get the class information, then I see that there is only ONE 'create' method that accepts Object only: public static org.opentest4j.ValueWrapper org.opentest4j.ValueWrapper.create(java.lang.Object). After that, I went to JAR file on my local machine, and it looks like version 1.2.0 contains only one 'create' method that accepts Object.

Could it be an issue with JAR file that you had uploaded to public maven repo?

Thank you!

vprudnikov commented 4 years ago

I found the solution The problem was with another dependency picked by maven: wiremock-jre8-standalone:2.26.2

The fix is to declare the dependency explicitly:

        <dependency>
            <groupId>org.opentest4j</groupId>
            <artifactId>opentest4j</artifactId>
            <version>1.2.0</version>
        </dependency>
marcphilipp commented 4 years ago

@vprudnikov Thanks for sharing the fix! 👍