1
我想用maven和junit運行我的黃瓜測試。當我使用黃瓜關鍵字@given,@when等時,它顯示錯誤爲包cucumber.api.java.en不存在。我嘗試使用maven版本3.3.9,下面是我的pom.xml。我不知道它是否依賴性不匹配或其他。任何人都可以幫助我。包cucumber.api.java.en不存在黃瓜
的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>
在maven依賴關係中檢查你的cucumber-java jar,包含註釋代碼的包應該在那裏。您可能希望將cucumber-html包含在依賴項中,儘管它與錯誤沒有任何關係。 – Grasshopper