Setting up your IDE - veepee-oss/gingerspec GitHub Wiki

A brief description of the preferred IDE and the configuration and extra packages that need to be download to make working with Gingerspec/Selenium/Cucumber much easier.

Recommended IDE

There are many different IDE's to work specifically with Java projects. We recommend the use of "Intellij IDEA". You can download the IDE for your operating system using this link. If this is your first time using this IDE, we strongly suggest you take a look at the official documentation here.

Assuming you have already created a GingerSpec based project by following the instructions in the getting started section, you can proceed to import your project to Intellij as described here

Plugins

Plugins extend the core functionality of IntelliJ IDEA:

Adding pluggins

For working with Cucumber, we recommend the installation of the following plugins in Intellij:

These plugins will make it much easier to work with Feature files in Intellij, as well as providing code suggestions, step completion, and some other useful tools. Check the documentation on managing plugins for more information on how to install them

Getting GingerSpec steps documentation

You can access the Javadoc documentation for most GingerSpec steps directly from Intellij. The Javadoc contains not only a brief description of the step, but also it provides examples of how to use the step and also links to other related/relevant steps. This information is the same that you can directly find in the GingerSpec Javadoc. The documentation is visible once you hover the mouse over the desired step just like this:

Step javadoc

This documentation is not downloaded by default, but it can be easily downloaded directly from Intellij IDEA Maven tool window with the option Download Sources or/and Documentation (read the official documentation for how to access this window for your specific OS).

Download sources and documentation

Running tests with your IDE

Besides running your tests using the command line as explained here, you can also use IntelliJ IDEA to directly run your Feature files or even individual Scenarios with a simple click. This makes it much easier to run your tests and can save you a bunch of time when debugging 😲

Running TestNG test

Intellij IDEA allows running individual tests classes

running a test

In the case of a GingerSpec project, the runner classes are test classes. If you don't remember what runner classes are, please check the information here. Go ahead and open a runner class and just click run (like in the above picture), or just right-click the java class and click run. Check how to run tests in the Intellij IDEA documentation to know more.

In some more recent version of TestNG, you may find the error: "TestNG by default disables loading DTD from unsecured Urls. If you need to explicitly load the DTD from an HTTP url, please do so by using the JVM argument [-Dtestng.dtd.http=true]". To fix this, you will have to add the parameter -Dtestng.dtd.http=true in the VM options of your Run/debug configurations in Intellij IDEA for TestNG. You can follow the instruction provided here to change the Run/debug configuration templates. Basically, click on Edit configurations -> Templates -> TestNG. In the field VM options just add

-Dtestng.dtd.http=true

Check also the instruction detailed in this thread where the process is nicely explained.

Running cucumber test

You can also directly run a Feature file or even a Scenario directly in Intellij IDEA with a simple click 😉:

running cucumber tests

GingerSpec makes use of aspectj internally. This is what makes possible many of the GingerSpec functionality like gherkin tags or gherkin variables. If AspectJ is not added as a VM argument when running your tests, some of the GingerSpec functionality may not work

This can easily be fixed by telling Intellij IDEA to add the reference to the AspectJ library during the test startup. For this, we will make use of IntelliJ IDEA's Run/debug configurations. My recommendation would be to add this parameter to the Cucumber Java template, in this way, you will only have to set this once and the same configuration will be applied every time you run a new Cucumber Java test.

You can follow the instruction provided here to change the Run/debug configuration templates. Basically, click on Edit configurations -> Templates -> Cucumber Java. In the field VM options add the reference to AspectJ:

-javaagent:$MAVEN_REPOSITORY$/org/aspectj/aspectjweaver/1.9.5/aspectjweaver-1.9.5.jar

PRO Tip: Besides this, I would also recommend you to include in the template the following argument in the section Program arguments (the order of plugins is important)

--plugin com.privalia.qa.cucumber.reporter.TestNGPrettyFormatter --plugin org.jetbrains.plugins.cucumber.java.run.CucumberJvm5SMFormatter

This will allow you to also visualize the variable's value when you click on a specific step during the execution 😉

Configuring Cucumber Java Run/Debug configuration template

After this, you should be able to directly run your Feature/Scenario by a simple click in Intellij IDEA

Running a Cucumber Java test directly in Intellij IDEA

If you want more info on running cucumber tests, you can check the documentation for running cucumber tests directly on the Intellij IDEA page.