我正在尝试使用maven和junit运行cucumber测试。当我使用cucumber关键字@given,@when等时,它显示错误package cucumber.API.java.en does not exist。我尝试使用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>
3条答案
按热度按时间dphi5xsq1#
试试@When,@Given。大写很重要。
xbp102n02#
将TestRunner.java类和步骤定义放在src/test/java目录下,将特性文件放在src/test/resources目录下
bmp9r5qi3#
在我的项目中,我用这个更新了POM.XML,它可以工作: