A.4. Spock tests in your IDE

Because Spock tests are in Groovy, the support of Spock in your IDE will be as good as the existing support for Groovy. As explained previously, you don’t need to install Groovy support in your IDE in order to run Spock tests. It’s a nice-to-have feature because of its syntax highlighting and autocomplete facilities. The only thing specific to Spock is the test output result that should be set up to use a fixed-width font so that failure messages show up properly. For more information, see http://www.groovy-lang.org/ides.html. I use Eclipse, but Groovy is supported on most major environments.

A.4.1. Spock in Eclipse

To gain Groovy support in Eclipse, install either the vanilla Groovy plugin or the full-featured Groovy/Grails plugin. Both can be found in the Eclipse marketplace, as shown in figure A.1. The Eclipse marketplace is accessible from the Help > Marketplace menu.

Figure A.1. Eclipse plugins for Groovy

Once you do that, Groovy/Spock files will gain syntax highlighting and autocomplete support, as shown in figure A.2.

You can still use the Maven/Gradle commands to compile and run Spock tests.

Figure A.2. Groovy support in Eclipse

There’s also a plugin dedicated to Spock, but upon installing it, I haven’t noticed any additional functionality (it also depends on the Groovy plugin, so it isn’t a true alternative). You can find it in the Eclipse marketplace, as shown in figure A.3.

Figure A.3. Jspresso Spock plugin (optional)

A.4.2. Spock in the IntelliJ IDE

Groovy support in IntelliJ IDEA is built in, so there’s no need to download an external plugin. You need only to enable it, as shown in figure A.4.

Figure A.4. Enabling Groovy support in IntelliJ

When the Groovy plugin is enabled, you gain syntax highlighting and autocomplete in Groovy files, as shown in figure A.5.

Figure A.5. Groovy support in IntelliJ IDEA

Again, as with Eclipse, you can still use the command-line Maven/Gradle commands to compile and run Spock tests. A dedicated Spock plugin for IntelliJ IDEA adds extra optional goodies, such as syntax highlighting for Spock labels (see figure A.6).

Figure A.6. IntelliJ plugin for Spock

Again, this is something that’s nice to have, but is not otherwise essential for running Spock tests.

A.4.3. Spock in NetBeans

I haven’t tried NetBeans with Groovy, but it also supports Groovy. See https://netbeans.org/features/groovy/ for more details.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.142.135.249