gpt4 book ai didi

testing - 从命令行运行 Karate 测试返回 surefire-plugin 错误

转载 作者:行者123 更新时间:2023-11-28 20:13:23 27 4
gpt4 key购买 nike

我一直在尝试从命令行运行我的.feature Karate 文件。我一直在尝试关注 docs ,所以我找到了以下说明:

mvn test -Dtest=CatsRunner

当我运行上面的命令时,我看到我的测试正在运行,并且所有测试都通过了。但是,在我的命令行末尾弹出了一些错误。以下是日志部分:

1 Scenarios (1 passed)
16 Steps (16 passed)
0m2.388s
Karate version: 0.8.0
html report: (paste into browser to view)
-----------------------------------------
file:/D:/Dev/xxx/yyy/karate/target/surefire-reports/TEST-tvplus.singleuseroperations.authenticate.auth-existing-IPTV-user.html

[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 4.302 s - in tvplus.singleuseroperations.authenticate.AuthenticateRunner
[INFO]
[INFO] Results:
[INFO]
[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 14.204 s
[INFO] Finished at: 2018-12-12T15:50:06+03:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.22.1:test (default-test) on project karate: No tests were executed!
(Set -DfailIfNoTests=false to ignore this error.) -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1]
http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

我还在下面粘贴我的 pom 文件:

<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.xxx.yyy.zzz</groupId>
<artifactId>karate</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
<maven.compiler.version>3.6.0</maven.compiler.version>
<karate.version>0.8.0</karate.version>
<jdbc.version>5.1.3.RELEASE</jdbc.version>
<maven.surefire.version>2.22.1</maven.surefire.version>
</properties>

<dependencies>
<dependency>
<groupId>com.intuit.karate</groupId>
<artifactId>karate-apache</artifactId>
<version>${karate.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.intuit.karate</groupId>
<artifactId>karate-junit4</artifactId>
<version>${karate.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>${jdbc.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc6</artifactId>
<version>11.2.0.4</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.intuit.karate</groupId>
<artifactId>karate-testng</artifactId>
<version>${karate.version}</version>
</dependency>
<dependency>
<groupId>com.intuit.karate</groupId>
<artifactId>karate-core</artifactId>
<version>${karate.version}</version>
</dependency>
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12.4</version>
</dependency>

</dependencies>

<build>
<testResources>
<testResource>
<directory>src/test/java</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</testResource>
</testResources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven.compiler.version}</version>
<configuration>
<encoding>UTF-8</encoding>
<source>${java.version}</source>
<target>${java.version}</target>
<compilerArgument>-Werror</compilerArgument>
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven.surefire.version}</version>
<configuration>
<argLine>-Dfile.encoding=UTF-8</argLine>
</configuration>
</plugin>
</plugins>
</build>

此外,这是我的CatsRunner.java:

package xyz;

import com.intuit.karate.junit4.Karate;
import cucumber.api.CucumberOptions;
import org.junit.runner.RunWith;

@RunWith(Karate.class)
@CucumberOptions(features = "classpath:xxx/singleuseroperations/authenticate/auth-existing-user.feature")

public class CatsRunner {
}

编辑:以下部分与问题无关。无需考虑。升级 Karate 版本解决了这个问题。我一直在运行程序类的顶部使用 @CucumberOptions,因为我在向代码添加 @KarateOptions 注释时遇到了一些问题。

提前致谢。

最佳答案

要消除 surefire-plugin 错误,您可能需要将 DfailIfNoTests=false 添加到命令行运行脚本。 Surefire 插件与您编写的测试集成在一起。此选项将编译并运行您的测试,但如果某些测试失败,则整个构建不会失败。

关于testing - 从命令行运行 Karate 测试返回 surefire-plugin 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53743667/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com