...所以我创建了一个实用程序,它允许我用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中使用它.