-
Create a new Maven project:
Note: If you use Java 9, you may need to explicitly configure your project to be compiled to version 1.6 or later: Java
…
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
</build>
…Otherwise, the project will be compiled to version 1.5 that Java 9 does not support, and an error may occur.
-
Put the following dependencies to the pom.xml file:
-
To add Cucumber libraries to your project, use the following dependencies:
pom.xml
<dependencies>
...
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-java</artifactId>
<version>2.3.1</version>
<scope>test</scope>
</dependency>
...
</dependencies> -
To run Cucumber tests with the JUnit runner, add the following dependencies:
pom.xml
<dependencies>
...
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-junit</artifactId>
<version>2.3.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
...
</dependencies> -
Add a reference to the TestLeft library. It is located in the <TestLeft>\API\Java folder.
pom.xml
<dependencies>
...
<dependency>
<groupId>com.smartbear.testleft</groupId>
<artifactId>testleft</artifactId>
<version>2.42</version>
<scope>system</scope>
<systemPath><TestLeft 2>/API/Java/testleft-2.42.jar</systemPath>
</dependency>
...
</dependencies> -
Also, TestLeft requires the following dependencies:
pom.xml
<dependencies>
...
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.2</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.3</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-compress</artifactId>
<version>1.15</version>
</dependency>
...
</dependencies>
-
Note: | After you specify new dependencies, the Maven project may need to download new libraries. To do that in IntelliJ IDEA, click Import Changes, or click Enable Auto-Import to allow the IDE to do that automatically: |
See Also
Behavior-Driven Development
About Behavior-Driven Development