2

我创建了我的第一个功能,它运行得非常棒。但是我没有在我的目标文件夹中看到以下类型的 html 报告。你能帮我吗?https://github.com/intuit/karate/blob/master/karate-demo/src/test/resources/karate-maven-cucumber-reporting.png

4

2 回答 2

3

我想我已经要求您在另一个答案中更仔细地阅读文档。无论如何,这是链接:

https://github.com/intuit/karate/tree/master/karate-demo#example-report

将此添加到您的pom.xml

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

然后添加一个src/test/java/log4j2.properties包含以下内容的文件:

log4j.rootLogger = INFO, CONSOLE
log4j.appender.CONSOLE = org.apache.log4j.ConsoleAppender
log4j.appender.CONSOLE.layout = org.apache.log4j.PatternLayout

有关更多详细信息,请参阅文档,但请使用并行运行器:

@Test
public void testParallel() {
    String karateOutputPath = "target/surefire-reports";
    KarateStats stats = CucumberRunner.parallel(getClass(), 5, karateOutputPath);
    generateReport(karateOutputPath);
    assertTrue("there are scenario failures", stats.getFailCount() == 0);        
}

private static void generateReport(String karateOutputPath) {
    Collection<File> jsonFiles = FileUtils.listFiles(new File(karateOutputPath), new String[] {"json"}, true);
    List<String> jsonPaths = new ArrayList(jsonFiles.size());
    for (File file : jsonFiles) {
        jsonPaths.add(file.getAbsolutePath());
    }
    Configuration config = new Configuration(new File("target"), "your-project-name");
    ReportBuilder reportBuilder = new ReportBuilder(jsonPaths, config);
    reportBuilder.generateReports();    
}
于 2017-08-12T03:04:20.170 回答
-1

假设您正在寻找黄瓜报告。

@CucumberOptions(features = {"src/test/java/features"},glue={"stepDef"},format={"pretty", "html:target/Destination"})

format={"pretty", "html:target/Destination"}指定要存储黄瓜 html 报告的文件夹的路径

于 2017-08-11T19:36:14.063 回答