我正在尝试使用 maven 和 junit 运行我的 cucumber 测试。当我使用 cucumber 关键字 @given、@when 等时,它显示的错误为 包cucumber.api.java.en 不存在 .我尝试使用 maven 3.3.9 版,以下是我的 pom.xml。我不知道这是依赖不匹配还是其他什么。任何人都可以帮助我。
pom.xml:
<dependencies>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-java</artifactId>
<version>1.2.5</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-core</artifactId>
<version>1.2.5</version>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>gherkin</artifactId>
<version>2.12.2</version>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-junit</artifactId>
<version>1.2.5</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<!-- <dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
<type>maven-plugin</type>
</dependency> -->
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>3.3.9</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>
maven-compiler-plugin
</artifactId>
<version>3.5.1</version>
<!-- <configuration>
<source>1.7</source>
<target>1.7</target>
<encoding>UTF-8</encoding>
</configuration> -->
</plugin>
</plugins>
</build>
最佳答案
将您的 TestRunner.java 类和步骤定义放在 src/test/java 目录下,将特性文件放在 src/test/resources 目录下
关于java - 包cucumber.api.java.en 不存在cucumber,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40739443/