JSON 空手道框架报告

JSON report for Karate Framework

如何在使用空手道框架时生成 JSON 报告,以便我可以使用黄瓜报告插件在 JENKINS 中使用它。 我的空手道版本是: 空手道阿帕奇 - 0.8.0 空手道 junit4 - 0.8.0

你真的应该阅读文档:https://github.com/intuit/karate/tree/master/karate-demo#example-report

<dependency>
    <groupId>net.masterthought</groupId>
    <artifactId>cucumber-reporting</artifactId>
    <version>3.8.0</version>
    <scope>test</scope>
</dependency>

public static void generateReport(String karateOutputPath) {
    Collection<File> jsonFiles = FileUtils.listFiles(new File(karateOutputPath), new String[] {"json"}, true);
    List<String> jsonPaths = new ArrayList(jsonFiles.size());
    jsonFiles.forEach(file -> jsonPaths.add(file.getAbsolutePath()));
    Configuration config = new Configuration(new File("target"), "demo");
    ReportBuilder reportBuilder = new ReportBuilder(jsonPaths, config);
    reportBuilder.generateReports();        
}