Here I provide step-by-step instructions on how to import a chapter in Eclipse and run a Spock test. This section refers to chapter 1, but all chapters work in the same way.
Check out the source code and place it somewhere on your local filesystem.[2] Then, from Eclipse, choose File > Import and select a Maven project, as shown in figure A.8.
Your Eclipse workspace is a good place as it will make things easier.
Navigate to the folder that contains the chapter code and click the Finish button in the dialog box that appears, as shown in figure A.9.
Eclipse will attempt to find connectors for the Gmaven-plus plugin and will fail because this plugin is fairly new (see figure A.10). Choose to ignore this (it won’t affect your build in any way). When you work with cutting-edge technology like Spock, your IDE can’t keep up with you!
Next, make sure that the src/test/groovy directory is handled as a source directory, as shown in figure A.11:
To build the project, you can run mvn test from the command line. Alternatively, in Eclipse, you can choose “Maven test” from the project right-click menu, as shown in figure A.12.
Then you can individually run any Spock test exactly as you would run a JUnit test (by right-clicking it), as shown in figure A.13.
The results of the test appear in the JUnit console, as shown in figure A.14.
3.21.98.207