Spock 2 doesn't work in IntelliJ IDEA 2021.2 Ultimate
1. Create a new Maven project: File -> New -> Project -> Maven -> (no archetype) -> Next -> Finish
2. Add Spock 2.0 dependency to pom.xml:
<dependencies>
<dependency>
<groupId>org.spockframework</groupId>
<artifactId>spock-core</artifactId>
<version>2.0-groovy-3.0</version>
<scope>test</scope>
</dependency>
</dependencies>
3. Load Maven changes (Ctrl-Shift-O)
4. Create directory src/test/groovy under the already existing src/test
5. Right click, Mark Directory as... -> Test Sources Root
6. Right click on the new directory, choose New -> Groovy class, "FooSpec"
7. Insert:
import spock.lang.Specification
class FooSpec extends Specification{
def "foo"() {
expect: 1 == 1
}
}
8. Click "Run FooSpec" in the gutter the first time. The test will run. Gutter icons will change
9. Click "Run FooSpec" or the individual test again. No test will run from now on.
/usr/lib/jvm/adoptopenjdk-8-hotspot-amd64/bin/java ...
!!! JUnit version 3.8 or later expected:
java.lang.ClassNotFoundException: junit.framework.ComparisonFailure
at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352)
at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at com.intellij.rt.junit.JUnitStarter.junitVersionChecks(JUnitStarter.java:214)
at com.intellij.rt.junit.JUnitStarter.canWorkWithJUnitVersion(JUnitStarter.java:198)
at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:46)
Process finished with exit code 253
Everything seems to work using version "1.3-groovy-2.5".
Please sign in to leave a comment.
Please see https://youtrack.jetbrains.com/issue/IDEA-274589.
The fix is available in 2021.2.1 RC: https://confluence.jetbrains.com/display/IDEADEV/IDEA+2021.2+latest+builds .
Nice, thanks!