Reputation: 1748
I get a NoSuchMethodError on AssertJ when I try to execute a unit test. The make step works fine and when navigating to the implementation of assertThat(), it works just fine.
The module dependencies show that I am using org.assertj:assertj-code:1.2.0 as I have defined as compile dependency in my build.gradle (yes, compile and not test). The unit test resides inside the main classpath of my module since it is an integration test, so this is intentional. The iml file contains:
<orderEntry type="library" name="Gradle: org.assertj:assertj-core:1.2.0" level="project" />
My example test is:
import org.assertj.core.api.Assertions;
import org.junit.Test;
public class X {
@Test
public void x(){
Assertions.assertThat(1).isEqualTo(1);
}
}
and when I execute it, I get:
java.lang.NoSuchMethodError: org.assertj.core.api.Assertions.assertThat(I)Lorg/assertj/core/api/IntegerAssert;
When I look in the run configurations, the classpath is set to the correct module (the module containing AssertJ).
I have tried invalidating caches but that did not help.
I am currently out of ideas (no pun intended). Anyone out there who has seen this before? Or have a clue on how to proceed troubleshooting?
Upvotes: 1
Views: 4105
Reputation: 1748
Found it.
I had another module importing a newer version of AssertJ. And somehow (seems like a bug in IntelliJ) my runtime was using that one instead.
I will keep track of my reported bug: https://youtrack.jetbrains.com/issue/IDEA-156718 and post updates.
Upvotes: 2