6b) Create a New Project

This document is not up-to-date anymore. To be reviewed.




Prerequisite

Before creating a new project, make sure that you've done the initial setup.

Configuration:

  • Create a new project in IntelliJ. E.g. "test-project"
    • Maven module
    • Don't select maven archetype
  • Unzip the base structure in the folder where you created the module
    • After unzipping, you should have the following folder structure:
test-project/
  features/
    demo feature.feature
  src/
    test/
      resources/
        properties/
          default.properties
        cucumber.xml
        ctf.properties
  pom.xml

 

  • Use the commandline to go to the folder where "pom.xml" is located and execute mvn -U compile
    • After this, you should have the following folder structure:
 test-project/
  ctf-source/
    ctf-source.jar
  ...
  • Open the Maven tab in IntelliJ (on the right side) and choose "Reimport all Maven projects" (refresh button)
  • Configure the test sources folder in IntelliJ
    • File -> Project Structure -> Modules



    • Select your module and go to the Sources tab
    • On the right, click on '+ Add Content Root' and chose the file ctf-source\ctf-source.jar



    • On the left, chose thee heading ending on ctf-source.jar!
    • On the right, select the most upper item (again ctf-source.jar) and select Test Sources



  • Create a local properties file (if you DON'T SAHI installation in c:\sahi staat) in ${user.home}\dev-configs\* (create if not yet present) so you can enter the SAHI paths & the default browser.
    • The name of the properties file can be found in the cucumber.xml and can be adjusted per project.

Your project is now ready to be executed. And you can also e.g. add it to your Git repo.

 

Make sure that the cucumber-java plugin is active in IntelliJ. Also make sure the Ruby plugin is NOT active (when you have that plugin). With the current versions of the plugins, there are compatibility problems. We expect these to be resolved in the future.

You can check the plugins via File -> Other Settings -> Configure Plugins or via File -> Settings -> Plugins.

Make sure that the SAHI proxy is running and Firefox (or your other preferred; configurated browser) is not runing

    • Running SAHI is done by executing sahi.bat (in C:\sahi\bin\ or equivalent location)
    • If you get an error message that the chosen browser can't be found, adjust the location of the browser.exe in the specified location. Probably C\sahi\userdata\config\browser_types.xml and execute the sahi.bat again.

To execute a feature:

  • Open demo feature.feature
  • Right-click on Scenario: Some demo scenario
  • Select Run

When all goes well, you get all the necessary feedback within IntelliJ.

Common issue: 'step undefined' error

Typically, when running features; IntelliJ should automaticaly fill in the Glue directory. When working with IntelliJ 13 however, this sometimes seems to fail, for all feature steps resulting in the message 'step undefined'. Alternatively, Cucumber may fail to recognize custom cuke packages that are not part of the general com.foreach.cuke.ctf package. These solutions to these two related issues are discussed below.

Issue 1: all steps are undefined

If this issue presents itself, do the following: at the top right of the IntelliJ window, choose 'Edit configuration' after clicking the dropdown box.


Under 'Defaults', fill in the Glue package: com.foreach.cuke.ctf, and press 'OK'. This should resolve the issue.

 

Additionally, it's also possible to do this for separate features, which will be available above 'Defaults' once the feature in question has been run at least once: for the feature, select the Deployment' tab, fill in the Glue package: com.foreach.cuke.ctf, and press 'OK'.

Issue 2: a custom step is undefined

Taking restobookings' tablemanager as an example, do the following:

  • Go to 'Edit configurations' and 'Defaults' as described above
  • At the 'Glue' line click the button at the right
  • On the a new line add the required cuke package and press 'OK'
  • IntelliJ should now have added the second package to the glue line