Cha*_*hai 1 java junit intellij-idea cucumber maven
我一直在努力使它起作用。
我想建立一个测试运行器类,像这样
但是我得到这个错误:
错误:(3,26)Java:包 Cucumber.api.junit 不存在
错误:(10,10)Java:找不到符号
符号:类Cucumber
该类如下所示:
package nl.prvgld.sigma.aanvraagtitels.testutil;
import cucumber.api.junit.Cucumber;
import org.junit.runner.RunWith;
@RunWith(Cucumber.class)
public class RunFeature {
}
Run Code Online (Sandbox Code Playgroud)
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>
Run Code Online (Sandbox Code Playgroud)
所有类都在“测试”文件夹下的某个位置。我一直在这里查看一些相关问题,并尝试了一些解决方案,例如从Pom中删除测试,并确保我在Pom中具有junit,cucumber-junit,cucumber-java8和cucumber-core。
我正在使用Intellij。
朝正确方向提供的任何帮助均受到高度赞赏!
干杯!
通过检查,一切看起来都很好。但显然,它并没有按照你的预期工作。
用IDEA编译和用Maven编译有同样的错误吗?
首先,我将从 Cucumber 团队克隆一个入门项目并使其运行。以后扩展它以包含您需要的东西要容易得多。克隆https://github.com/cucumber/cucumber-java-sculpture并使用 Maven 构建它
mvn clean install
Run Code Online (Sandbox Code Playgroud)
预计它可以开箱即用。
有了可行的解决方案,朝着您真正想要的项目迈出一小步。
| 归档时间: |
|
| 查看次数: |
8713 次 |
| 最近记录: |