I made a java project with maven to run cucumber tests through junit, but the test phase never launches.
pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.github.javatlacati</groupId>
<artifactId>unodostres</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
<cucumber.version>4.7.1</cucumber.version>
<maven.compiler.version>3.3</maven.compiler.version>
<junit.version>4.12</junit.version>
<surefire.plugin.version>2.19.1</surefire.plugin.version>
</properties>
<dependencies>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.47.1</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-java</artifactId>
<version>${cucumber.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-junit</artifactId>
<version>${cucumber.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${surefire.plugin.version}</version>
<configuration>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven.compiler.version}</version>
<configuration>
<encoding>UTF-8</encoding>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
When running the tests using
mvn verify -B
I get the following output:
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ unodostres ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.3:testCompile (default-testCompile) @ unodostres ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.19.1:test (default-test) @ unodostres ---
INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ unodostres ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.359 s
This is my project structure:
unodostres
├───.idea
│ └───libraries
└───src
├───main
│ ├───java
│ │ └───com
│ │ └───github
│ │ └───javatlacati
│ │ └───unodostres
│ │ └───pages
│ └───resources
└───test
├───java
│ └───steps
└───resources
How can I solve that?
Attempts
I have managed to run my class from the IDE, UserHistoryRunner
which is the one with the unit test, using the following command:
"C:\Program Files\Zulu\zulu-12\bin\java.exe" -ea -Didea.test.cyclic.buffer.size=1048576 "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA 2019.1.3\lib\idea_rt.jar=51804:C:\Program Files\JetBrains\IntelliJ IDEA 2019.1.3\bin" -Dfile.encoding=UTF-8 -classpath "C:\Program Files\JetBrains\IntelliJ IDEA 2019.1.3\lib\idea_rt.jar;C:\Program Files\JetBrains\IntelliJ IDEA 2019.1.3\plugins\junit\lib\junit-rt.jar;C:\Program Files\JetBrains\IntelliJ IDEA 2019.1.3\plugins\junit\lib\junit5-rt.jar;C:\Users\Ivana Martinez C\Documents\CoolBeansProjects\unodostres\target\test-classes;C:\Users\Ivana Martinez C\Documents\CoolBeansProjects\unodostres\target\classes;C:\Users\Ivana Martinez C\.m2\repository\org\seleniumhq\selenium\selenium-java\2.47.1\selenium-java-2.47.1.jar;C:\Users\Ivana Martinez C\.m2\repository\org\seleniumhq\selenium\selenium-chrome-driver\2.47.1\selenium-chrome-driver-2.47.1.jar;C:\Users\Ivana Martinez C\.m2\repository\org\seleniumhq\selenium\selenium-remote-driver\2.47.1\selenium-remote-driver-2.47.1.jar;C:\Users\Ivana Martinez C\.m2\repository\cglib\cglib-nodep\2.1_3\cglib-nodep-2.1_3.jar;C:\Users\Ivana Martinez C\.m2\repository\com\google\code\gson\gson\2.3.1\gson-2.3.1.jar;C:\Users\Ivana Martinez C\.m2\repository\org\seleniumhq\selenium\selenium-api\2.47.1\selenium-api-2.47.1.jar;C:\Users\Ivana Martinez C\.m2\repository\com\google\guava\guava\18.0\guava-18.0.jar;C:\Users\Ivana Martinez C\.m2\repository\org\seleniumhq\selenium\selenium-edge-driver\2.47.1\selenium-edge-driver-2.47.1.jar;C:\Users\Ivana Martinez C\.m2\repository\commons-io\commons-io\2.4\commons-io-2.4.jar;C:\Users\Ivana Martinez C\.m2\repository\org\apache\commons\commons-exec\1.3\commons-exec-1.3.jar;C:\Users\Ivana Martinez C\.m2\repository\org\seleniumhq\selenium\selenium-htmlunit-driver\2.47.1\selenium-htmlunit-driver-2.47.1.jar;C:\Users\Ivana Martinez C\.m2\repository\net\sourceforge\htmlunit\htmlunit\2.17\htmlunit-2.17.jar;C:\Users\Ivana Martinez C\.m2\repository\xalan\xalan\2.7.2\xalan-2.7.2.jar;C:\Users\Ivana Martinez C\.m2\repository\xalan\serializer\2.7.2\serializer-2.7.2.jar;C:\Users\Ivana Martinez C\.m2\repository\commons-collections\commons-collections\3.2.1\commons-collections-3.2.1.jar;C:\Users\Ivana Martinez C\.m2\repository\org\apache\commons\commons-lang3\3.4\commons-lang3-3.4.jar;C:\Users\Ivana Martinez C\.m2\repository\org\apache\httpcomponents\httpmime\4.4.1\httpmime-4.4.1.jar;C:\Users\Ivana Martinez C\.m2\repository\commons-codec\commons-codec\1.10\commons-codec-1.10.jar;C:\Users\Ivana Martinez C\.m2\repository\net\sourceforge\htmlunit\htmlunit-core-js\2.17\htmlunit-core-js-2.17.jar;C:\Users\Ivana Martinez C\.m2\repository\xerces\xercesImpl\2.11.0\xercesImpl-2.11.0.jar;C:\Users\Ivana Martinez C\.m2\repository\xml-apis\xml-apis\1.4.01\xml-apis-1.4.01.jar;C:\Users\Ivana Martinez C\.m2\repository\net\sourceforge\nekohtml\nekohtml\1.9.22\nekohtml-1.9.22.jar;C:\Users\Ivana Martinez C\.m2\repository\net\sourceforge\cssparser\cssparser\0.9.16\cssparser-0.9.16.jar;C:\Users\Ivana Martinez C\.m2\repository\org\w3c\css\sac\1.3\sac-1.3.jar;C:\Users\Ivana Martinez C\.m2\repository\commons-logging\commons-logging\1.2\commons-logging-1.2.jar;C:\Users\Ivana Martinez C\.m2\repository\org\eclipse\jetty\websocket\websocket-client\9.2.11.v20150529\websocket-client-9.2.11.v20150529.jar;C:\Users\Ivana Martinez C\.m2\repository\org\eclipse\jetty\jetty-util\9.2.11.v20150529\jetty-util-9.2.11.v20150529.jar;C:\Users\Ivana Martinez C\.m2\repository\org\eclipse\jetty\jetty-io\9.2.11.v20150529\jetty-io-9.2.11.v20150529.jar;C:\Users\Ivana Martinez C\.m2\repository\org\eclipse\jetty\websocket\websocket-common\9.2.11.v20150529\websocket-common-9.2.11.v20150529.jar;C:\Users\Ivana Martinez C\.m2\repository\org\eclipse\jetty\websocket\websocket-api\9.2.11.v20150529\websocket-api-9.2.11.v20150529.jar;C:\Users\Ivana Martinez C\.m2\repository\org\apache\httpcomponents\httpclient\4.4.1\httpclient-4.4.1.jar;C:\Users\Ivana Martinez C\.m2\repository\org\apache\httpcomponents\httpcore\4.4.1\httpcore-4.4.1.jar;C:\Users\Ivana Martinez C\.m2\repository\org\seleniumhq\selenium\selenium-firefox-driver\2.47.1\selenium-firefox-driver-2.47.1.jar;C:\Users\Ivana Martinez C\.m2\repository\org\seleniumhq\selenium\selenium-ie-driver\2.47.1\selenium-ie-driver-2.47.1.jar;C:\Users\Ivana Martinez C\.m2\repository\net\java\dev\jna\jna\4.1.0\jna-4.1.0.jar;C:\Users\Ivana Martinez C\.m2\repository\net\java\dev\jna\jna-platform\4.1.0\jna-platform-4.1.0.jar;C:\Users\Ivana Martinez C\.m2\repository\org\seleniumhq\selenium\selenium-safari-driver\2.47.1\selenium-safari-driver-2.47.1.jar;C:\Users\Ivana Martinez C\.m2\repository\org\seleniumhq\selenium\selenium-support\2.47.1\selenium-support-2.47.1.jar;C:\Users\Ivana Martinez C\.m2\repository\org\webbitserver\webbit\0.4.14\webbit-0.4.14.jar;C:\Users\Ivana Martinez C\.m2\repository\io\netty\netty\3.5.2.Final\netty-3.5.2.Final.jar;C:\Users\Ivana Martinez C\.m2\repository\org\seleniumhq\selenium\selenium-leg-rc\2.47.1\selenium-leg-rc-2.47.1.jar;C:\Users\Ivana Martinez C\.m2\repository\junit\junit\4.12\junit-4.12.jar;C:\Users\Ivana Martinez C\.m2\repository\org\hamcrest\hamcrest-core\1.3\hamcrest-core-1.3.jar;C:\Users\Ivana Martinez C\.m2\repository\io\cucumber\cucumber-java\4.7.1\cucumber-java-4.7.1.jar;C:\Users\Ivana Martinez C\.m2\repository\io\cucumber\cucumber-core\4.7.1\cucumber-core-4.7.1.jar;C:\Users\Ivana Martinez C\.m2\repository\io\cucumber\gherkin\5.1.0\gherkin-5.1.0.jar;C:\Users\Ivana Martinez C\.m2\repository\io\cucumber\tag-expressions\1.1.1\tag-expressions-1.1.1.jar;C:\Users\Ivana Martinez C\.m2\repository\io\cucumber\cucumber-expressions\7.0.2\cucumber-expressions-7.0.2.jar;C:\Users\Ivana Martinez C\.m2\repository\io\cucumber\datatable\1.1.14\datatable-1.1.14.jar;C:\Users\Ivana Martinez C\.m2\repository\io\cucumber\datatable-dependencies\1.1.14\datatable-dependencies-1.1.14.jar;C:\Users\Ivana Martinez C\.m2\repository\org\apiguardian\apiguardian-api\1.1.0\apiguardian-api-1.1.0.jar;C:\Users\Ivana Martinez C\.m2\repository\io\cucumber\cucumber-junit\4.7.1\cucumber-junit-4.7.1.jar" com.intellij.rt.execution.junit.JUnitStarter -ideVersion5 -junit4 UserHistoryRunner
I solved the problem!
The class must be specified in the surefire plugin to execute them
.feature
as follows: