【问题标题】:I'm not getting JUnit HTML report in Karate我在空手道中没有收到 JUnit HTML 报告
【发布时间】:2018-08-16 19:11:59
【问题描述】:

我已经按照空手道文档中的步骤创建了一个项目,我运行了默认架构中给出的示例测试用例,我的案例通过了,但我没有收到任何报告

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

<groupId>com.poc.karate</groupId>
<artifactId>interacKarate</artifactId>
<version>0.0.1-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>
</properties>    

<dependencies>    
    <dependency>
        <groupId>com.intuit.karate</groupId>
        <artifactId>karate-junit4</artifactId>
        <version>0.2.7</version>
        <scope>test</scope>
    </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-surefire-plugin</artifactId>
            <version>2.10</version>
            <configuration>
            <argLine>-Dfile.encoding=UTF-8</argLine>
            </configuration>
     </plugin>
        <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>
    </plugins>        
</build>       

RunnerClass

package examples.users;

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

@RunWith(Karate.class)
public class UsersRunner {

}

我的功能文件是

功能:示例空手道测试脚本

背景: * 网址'https://jsonplaceholder.typicode.com'

场景:获取所有用户,然后通过id获取第一个用户

给定路径“用户” 当方法得到 然后状态 200

  • def first = response[0]

给定路径“用户”,first.id 当方法得到 然后状态 200

场景:创建用户,然后通过id获取

  • 默认用户 = """ { "name": "测试用户", “用户名”:“测试用户”, “电子邮件”:“test@user.com”, “地址”: { “街道”:“没有名字”, "套房": "Apt. 123", “城市”:“电力”, “邮政编码”:“54321-6789” } } """

给定网址“https://jsonplaceholder.typicode.com/users” 并请求用户 当方法发布时 然后状态 201

  • def id = response.id
  • print '创建的 id 是:' + id

我还缺少什么?

【问题讨论】:

    标签: maven junit karate cucumber-junit


    【解决方案1】:

    这是一个非常旧的空手道版本,我确定您遵循的是过时的说明。我建议你按照快速入门:https://github.com/intuit/karate#quickstart

    mvn archetype:generate \
    -DarchetypeGroupId=com.intuit.karate \
    -DarchetypeArtifactId=karate-archetype \
    -DarchetypeVersion=0.8.0 \
    -DgroupId=com.mycompany \
    -DartifactId=myproject
    

    【讨论】:

    • 感谢 Peter Thomas,您节省了我的时间。现在正在生成 Junit 报告。我如何生成带有饼图和其他图形内容的黄瓜报告。我需要添加任何外部东西还是只是运行测试,因为黄瓜很好?
    • 我做到了。谢谢,你能帮我做黄瓜测试报告吗?
    • @user2986491 是 - 请参阅此处的文档:github.com/intuit/karate/tree/master/karate-demo#example-report
    猜你喜欢
    • 1970-01-01
    • 2018-06-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-03-19
    相关资源
    最近更新 更多