当前位置: 首页 > 知识库问答 >
问题:

用Maven和Jenkins进行空手道Api测试

姜鸿
2023-03-14

我正在使用空手道缺省的arche类型,正如在空手道教程中提到的,并且使用Eclipse成功地运行了cucumber报告的测试,但是当我在Jenkins中使用相同的项目时,我会得到以下错误。我正在使用Java1.8和Cucumber-reporting工具,请帮助我解决这个问题,因为我怀疑这是项目结构的问题

    <===[JENKINS REMOTING CAPACITY]===>channel started
Executing Maven:  -B -f D:\CogsdaleWorkspace\karate-archetype\pom.xml clean test
[INFO] Scanning for projects...
[INFO] 
[INFO] ----------------------< com.mycompany:myproject >-----------------------
[INFO] Building myproject 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ myproject ---
[INFO] Deleting D:\CogsdaleWorkspace\karate-archetype\target
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ myproject ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory D:\CogsdaleWorkspace\karate-archetype\src\main\resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.6.0:compile (default-compile) @ myproject ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ myproject ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 10 resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.6.0:testCompile (default-testCompile) @ myproject ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to D:\CogsdaleWorkspace\karate-archetype\target\test-classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] /D:/CogsdaleWorkspace/karate-archetype/src/test/java/nexusportalapi/TestParallel.java:[3,24] package org.junit does not exist
[ERROR] /D:/CogsdaleWorkspace/karate-archetype/src/test/java/nexusportalapi/TestParallel.java:[3,1] static import only from classes and interfaces
[ERROR] /D:/CogsdaleWorkspace/karate-archetype/src/test/java/nexusportalapi/TestParallel.java:[11,17] package org.junit does not exist
[ERROR] /D:/CogsdaleWorkspace/karate-archetype/src/test/java/nexusportalapi/TestParallel.java:[34,10] cannot find symbol
  symbol:   class Test
  location: class nexusportalapi.TestParallel
[INFO] 4 errors 
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  4.046 s
[INFO] Finished at: 2019-12-18T07:25:48-06:00
[INFO] ------------------------------------------------------------------------
Waiting for Jenkins to finish collecting data
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.6.0:testCompile (default-testCompile) on project myproject: Compilation failure: Compilation failure:
[ERROR] /D:/CogsdaleWorkspace/karate-archetype/src/test/java/nexusportalapi/TestParallel.java:[3,24] package org.junit does not exist
[ERROR] /D:/CogsdaleWorkspace/karate-archetype/src/test/java/nexusportalapi/TestParallel.java:[3,1] static import only from classes and interfaces
[ERROR] /D:/CogsdaleWorkspace/karate-archetype/src/test/java/nexusportalapi/TestParallel.java:[11,17] package org.junit does not exist
[ERROR] /D:/CogsdaleWorkspace/karate-archetype/src/test/java/nexusportalapi/TestParallel.java:[34,10] cannot find symbol
[ERROR] symbol:   class Test
[ERROR] location: class nexusportalapi.TestParallel
[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文件

`http://maven.apache.org/xsd/maven-4.0.0.xsd“>4.0.0

<groupId>com.mycompany</groupId>
<artifactId>myproject</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.9.4</karate.version>
</properties>

<dependencies>
    <dependency>
        <groupId>com.intuit.karate</groupId>
        <artifactId>karate-apache</artifactId>
        <version>${karate.version}</version>

    </dependency>
    <dependency>
        <groupId>com.intuit.karate</groupId>
        <artifactId>karate-junit5</artifactId>
        <version>${karate.version}</version>

    </dependency>
    <dependency>
        <groupId>org.junit.jupiter</groupId>
        <artifactId>junit-jupiter-engine</artifactId>
        <version>5.4.0</version>

    </dependency>
    <dependency>
        <groupId>net.masterthought</groupId>
        <artifactId>cucumber-reporting</artifactId>
        <version>5.0.0</version>

    </dependency>
    <dependency>
        <groupId>org.apache.logging.log4j</groupId>
        <artifactId>log4j-core</artifactId>
        <version>2.1</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>2.22.2</version>
        </plugin>

    </plugins>


</build>

共有1个答案

游勇军
2023-03-14

仅凭这些信息很难看出这一点,你能尝试两件事吗:

  • 升级至Karate版本0.9.5.rc5
  • 使用我们测试过的cucumber-reporting库的版本:3.8.0-https://github.com/intuit/karate/tree/master/karate-demo#example-report

您处于解决此问题的最佳位置--但如果所有其他方法都失败,您可以尝试遵循此过程:https://github.com/intuit/karate/wiki/how-to-submit-an-issue

 类似资料:
  • 我无法在我的功能中运行空手道测试 不知道我错过了什么。对于api自动化世界来说是非常新的。非常感谢任何帮助。

  • 我使用vscode与空手道跑步者空手道独立(karate.jar0.9.6)。我正在努力调整空手道日志设置。 我做了回写测试。xml在几个文件夹中(连同karate.jar和我的功能文件,在src/test/resource中)。我还尝试通过修补karate Runner›karate jar:Command Line Args将logback-test.xml添加到java类路径,但到目前为止没

  • 我无法使用CLI执行测试。跑者工作。我正在使用版本0.9.5.rc5和maven命令:“mvn test-f pom.xml exec:java-dexec.mainclass=com.intuit.karate.cli.main-dexec.args='-d'-dexec.classpathscope=test” 以下是错误:ERROR com.intuit.karate-driver conf

  • 我们有一个具有以下结构的多模块项目 模块1 模块2 模块e2e 父pom 模块e2e包含我们的空手道功能(进入src/test/java/features文件夹) 我们不知道如何使用“mvn测试”进行空手道测试。它总是运行0个测试,而不是一些功能文件。 我们尝试从项目的根以及e2e模块内部运行“mvn测试” 我们还有其他maven项目(不是多模块项目),它可以按预期工作。需要进行一些配置操作吗?

  • 我想使用maven执行空手道测试,并将标记动态传递给执行。我使用的是junit4,我尝试了这两种方法--并行和简单的@Runwith注释。 @Runwith 使用这种方法,我可以动态地将标记传递给执行,但是如果空手道测试失败,maven构建仍然是成功的。 平行的 使用并行方法,如果空手道测试失败,maven构建将失败。但我无法通过maven命令选项将标记传递给测试。 我正在使用命令运行测试

  • Visual Studio代码1.43。0空手道独立罐0.9。5.RC5 在VScode编辑器中,在打开的空手道。功能文件中,代码“运行空手道测试”不再显示,如屏幕截图所示。因此,不可能调试特定的场景。对此有什么想法吗?多谢了。