繁体   English   中英

从命令行运行空手道测试会返回surefire-plugin错误

[英]Running Karate tests from commandline returns surefire-plugin error

我一直在尝试从命令行运行.feature空手道文件。 我一直在尝试遵循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 {
}

编辑:以下部分与问题无关。 无需考虑。 升级空手道版本解决了该问题。 我一直在运行器的顶部使用@CucumberOptions ,因为在向代码中添加@KarateOptions注释时遇到了一些麻烦。

提前致谢。

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

@KarateOptions仅在0.9.0中可用: https : //github.com/intuit/karate/releases/tag/v0.9.0

编辑:如果您简化pom.xml并避免使用空手道不需要的东西,您将能够使用“ surefire-plugin”解决问题。 这就是我试图通过将您指向以下链接来解释的内容: https : //github.com/intuit/karate/wiki/How-to-Submit-an-Issue

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM