Java: 包 cucumber.api.junit 不存在
Java: package cucumber.api.junit does not exist
我一直在努力让它发挥作用。
我想设置一个测试运行器classlike so
但是我得到这个错误:
Error:(3, 26) java: package cucumber.api.junit does not exist
Error:(10, 10) java: cannot find symbol
symbol: class Cucumber
class 看起来像:
package nl.prvgld.sigma.aanvraagtitels.testutil;
import cucumber.api.junit.Cucumber;
import org.junit.runner.RunWith;
@RunWith(Cucumber.class)
public class RunFeature {
}
Pom.xml 看起来像:
<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/maven-v4_0_0.xsd">
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
<modelVersion>4.0.0</modelVersion>
<groupId>nl.prvgld.sigma.aanvraagtitels</groupId>
<artifactId>Aanvraagtitels</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>Aanvraagtitels</name>
<url>http://maven.apache.org</url>
<dependencies>
<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.2.0</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/info.cukes/cucumber-java -->
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-java8</artifactId>
<version>1.2.5</version>
</dependency>
<!-- https://mvnrepository.com/artifact/info.cukes/cucumber-core -->
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-core</artifactId>
<version>1.2.5</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/info.cukes/cucumber-junit -->
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-junit</artifactId>
<version>1.2.5</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.microsoft.sqlserver/mssql-jdbc -->
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
<version>6.1.0.jre8</version>
</dependency>
<dependency>
<groupId>com.smartbear.readyapi.testserver.cucumber</groupId>
<artifactId>testserver-cucumber-core</artifactId>
<version>1.0.0</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
所有 classes 都在 Test 文件夹下的某个地方。
我在这里查看了一些相关问题并尝试了解决方案,例如从 Pom 中删除测试,并确保 Pom 中有 junit、cucumber-junit、cucumber-java8 和 cucumber-core。
我正在使用 Intellij。
非常感谢任何正确方向的帮助!
干杯!
经检查,一切正常。但显然,它并没有像你期望的那样工作。
用IDEA编译和用Maven编译有同样的错误吗?
首先,我将从 Cucumber 团队克隆一个入门项目并使其运行。以后扩展它以包含您需要的东西要容易得多。克隆 https://github.com/cucumber/cucumber-java-skeleton 并使用带有
的 Maven 构建它
mvn clean install
开箱即用。
有了可行的解决方案,朝着您真正想要的项目迈出一小步。
我不知道您是否已经解决了您的问题,但您可以通过从 pom.xml 文件中删除范围标签来快速修复它。对您遇到问题并且应该可以正常工作的所有依赖项执行此操作。
干杯,
哈
更改导入。
而不是: import cucumber.api.junit.Cucumber;
使用 import io.cucumber.junit.Cucumber;
我一直在努力让它发挥作用。
我想设置一个测试运行器classlike so
但是我得到这个错误:
Error:(3, 26) java: package cucumber.api.junit does not exist
Error:(10, 10) java: cannot find symbol
symbol: class Cucumber
class 看起来像:
package nl.prvgld.sigma.aanvraagtitels.testutil;
import cucumber.api.junit.Cucumber;
import org.junit.runner.RunWith;
@RunWith(Cucumber.class)
public class RunFeature {
}
Pom.xml 看起来像:
<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/maven-v4_0_0.xsd">
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
<modelVersion>4.0.0</modelVersion>
<groupId>nl.prvgld.sigma.aanvraagtitels</groupId>
<artifactId>Aanvraagtitels</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>Aanvraagtitels</name>
<url>http://maven.apache.org</url>
<dependencies>
<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.2.0</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/info.cukes/cucumber-java -->
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-java8</artifactId>
<version>1.2.5</version>
</dependency>
<!-- https://mvnrepository.com/artifact/info.cukes/cucumber-core -->
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-core</artifactId>
<version>1.2.5</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/info.cukes/cucumber-junit -->
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-junit</artifactId>
<version>1.2.5</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.microsoft.sqlserver/mssql-jdbc -->
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
<version>6.1.0.jre8</version>
</dependency>
<dependency>
<groupId>com.smartbear.readyapi.testserver.cucumber</groupId>
<artifactId>testserver-cucumber-core</artifactId>
<version>1.0.0</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
所有 classes 都在 Test 文件夹下的某个地方。 我在这里查看了一些相关问题并尝试了解决方案,例如从 Pom 中删除测试,并确保 Pom 中有 junit、cucumber-junit、cucumber-java8 和 cucumber-core。
我正在使用 Intellij。
非常感谢任何正确方向的帮助!
干杯!
经检查,一切正常。但显然,它并没有像你期望的那样工作。
用IDEA编译和用Maven编译有同样的错误吗?
首先,我将从 Cucumber 团队克隆一个入门项目并使其运行。以后扩展它以包含您需要的东西要容易得多。克隆 https://github.com/cucumber/cucumber-java-skeleton 并使用带有
的 Maven 构建它mvn clean install
开箱即用。
有了可行的解决方案,朝着您真正想要的项目迈出一小步。
我不知道您是否已经解决了您的问题,但您可以通过从 pom.xml 文件中删除范围标签来快速修复它。对您遇到问题并且应该可以正常工作的所有依赖项执行此操作。
干杯, 哈
更改导入。
而不是: import cucumber.api.junit.Cucumber;
使用 import io.cucumber.junit.Cucumber;