I need to generate a file that consolidates all the results of each feature execution?

空手道-DSL在JSON文件中 for each 已执行的特征文件生成测试结果.

enter image description here

推荐答案

...所以我创建了一个实用程序,它允许我用Java来完成这项工作.

我邀请您阅读README https://github.com/jesusop/karate-cucumber-xray

该方法读取空手道生成的所有json结果文件,并将它们统一到单个cucumber.json文件中

您还可以修改文件的路径:

private static final String JSON_DIRECTORY = "/cucumber-html-reports";
private static final String CUCUMBER_JSON = "/cucumber.json";
private static void writeResultsToOneFile(JSONArray totalResults) throws IOException {
        File currentDirectory = new File((new File(".")).getAbsolutePath());
        String absolutePath = currentDirectory.getCanonicalPath();

        File directory = new File(absolutePath + "/" + TARGET_DIRECTORY + JSON_DIRECTORY);
        if (!directory.exists()) {
            directory.mkdirs();
        }

        File cucumberJsonFile = new File(directory + CUCUMBER_JSON);
        try (FileWriter fileWriter = new FileWriter(cucumberJsonFile)) {
            fileWriter.write(totalResults.toJSONString());

        }

        logger.info("cucumber.json file has been created at: " + cucumberJsonFile.getAbsolutePath());
    }

请注意,测试完成后,您将收到如下消息:

INFO: cucumber.json file has been created at: ...\karate-cucumber-xray\target\cucumber-html-reports\cucumber.json

最后,您可以使用cucumber.json文件,并在Jira Xray API中使用它.

Java相关问答推荐

使用ExecutorService时在ThreadFactory中触发自定义newThread函数

Java 22模式匹配不适用于记录模式匹配.给出汇编问题

CriteriaQuery with max

H2弹簧靴试验跌落台

Quarkus keycloat配置不工作.quarkus. keycloak. policy—enforcer. enable = true在. yaml表示中不工作

Java 8中的多个字段和计数

在Spring终结点中,是否可以同时以大写和小写形式指定枚举常量?

将响应转换为带值的键

JOOQ中的子查询使用的是默认方言,而不是配置的方言

我的Spring Boot测试显示&IlLegalStateException:无法加载某事的ApplicationContext.

Spring安全令牌刷新和JWT签名与本地计算的签名不匹配

在Java中将int[]矩阵添加到ArrayList中,但出现错误

如果List是一个抽象接口,那么Collectors.toList()如何处理流呢?

Java中HashSet的搜索时间与TreeSet的搜索时间

如何处理两个几乎相同的XSD文件?

Java HashMap保留所有时间复杂性

如何制作回文程序?

当使用不同的参数类型调用时,为什么围绕Objects.equals的类型安全包装不会失败?

控制器建议异常处理

如何通过gradle命令行从build.gradle获得Java targetCompatibility