MikeHT (127) [Avatar] Offline
If I try to run any of the chapter 1 Spock tests from Eclipse (running them as JUnit tests) I get the following error:
"The input type of the launch configuration does not exist."

The tests will run if I go into the project directory and type "mvn test".

For giggles, I installed the Eclipse Spock plugin and was able to then run the InvoiceMailingSpec.groovy test, but it failed with the following exception:

Class not found InvoiceMailingSpec
java.lang.ClassNotFoundException: InvoiceMailingSpec
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.loadClass(RemoteTestRunner.java:688)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.loadClasses(RemoteTestRunner.java:421)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:444)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:678)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)

The AdderSpect.groovy, BetterSpec.groovy and MultiplierSpec.groovy tests would still not run (with the same error).
MikeHT (127) [Avatar] Offline
For anyone having the same problems, I found the solution. I used Spring STS version 3.8.4 as my IDE. This is of course Eclipse based. The reason I used this is because for some reason, I can't successfully load the Groovy-Eclipse plugin from a native Eclipse IDE. I had to do so from the Dashboard of STS, via the "IDE Extensions" link on the Dashboard.

Then, I added the "src/test/groovy" directory to the build path by clicking on the Project and going to "Build Path->Configure Build Path" then selecting "Add Folder". After adding this folder, click the "Output folder" under the folder you just added, then click "Edit", then click the "Specific output folder (relative to "chapter1") and enter "/target/test-classes" and save this config.

Finally, click on the project name again, go to "Configure->Convert to Groovy Project" and select this. I could then launch the spock test from Eclipse by directly clicking on a test and selecting "Run As->JUnit Test".
MikeHT (127) [Avatar] Offline
I forgot one other modification to make. The Groovy-Eclipse plugin will download groovy-all-2.4.11.jar while the spock-core in the pom will download groovy-all-2.4.1.jar. These will conflicth. Modify the spock-core dependency in the pom as follows:


This will exclude groovy-all-2.4.1.jar from the maven dependency. Then add in a dependency in the pom for groovy-all-2.4.11.jar:


Then you should be good to go.
Kostis Kapelonis (53) [Avatar] Offline

I am glad it worked for you!

Have you seen Appendix A of the book?

Some of the things you mention (such as adding the src/test/groovy folder as a source directory) are already mentioned there.

MikeHT (127) [Avatar] Offline
Yes, I saw appendix A, but it was lacking in some of the detailed steps, like fixing the conflict between the versions of groovy-all.jar. I still show an error in the pom file, but I can run the tests. Also, the appendix does not mention the fact that there is a problem loading the Groovy-Eclipse plugin or GGTS in a recent version of Eclipse such as Neon. I had to use a recent version of Spring STS to get an install of the Groovy-Eclipse plugin without any errors. Also, I don't think you can download the GGTS anymore in either a recent version of Eclipse or Spring STS. It does not seem to be in the marketplace.