Karate 未为空手道中的功能文件生成Cucumber报告

Karate 未为空手道中的功能文件生成Cucumber报告,karate,Karate,根据空手道文档,我使用了以下java代码和pom生成cucumber报告,但我无法获得预期的cucumber报告: 在Java类文件中: package Mav_demo.RunnerFunction; //import com.intuit.karate.junit4.Karate; import cucumber.api.CucumberOptions; import com.intuit.karate.cucumber.CucumberRunner; import com.intuit.

根据空手道文档,我使用了以下java代码和pom生成cucumber报告,但我无法获得预期的cucumber报告:

在Java类文件中:

package Mav_demo.RunnerFunction;

//import com.intuit.karate.junit4.Karate;
import cucumber.api.CucumberOptions;
import com.intuit.karate.cucumber.CucumberRunner;
import com.intuit.karate.cucumber.KarateStats;
//import org.junit.runner.RunWith;
import java.io.File;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import net.masterthought.cucumber.Configuration;
import net.masterthought.cucumber.ReportBuilder;
import org.apache.commons.io.FileUtils;
//import org.junit.BeforeClass;
import org.junit.Test;
import static org.junit.Assert.*;
//@RunWith(Karate.class)
//@CucumberOptions(features = 
"classpath:src/test/java/Mav_demo/RunnerFunction/gapi_mulscn.feature")
@CucumberOptions(tags = "~@ignore") 
public class Looping{

@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<String>(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();        
}
}
我确信火灾报告是正确的。但是,不是黄瓜报告。请帮忙


非常感谢……

很抱歉,没有人会读到所有这些,并弄明白,因为这似乎是黄瓜、硒和其他物质的可怕混合物

请参阅本文件:

不管怎样,我的建议是这样的。使用Maven quickstart(或原型)创建新项目:

然后让并行报告在该项目中工作。请参阅-并注意,您似乎正在使用cucumber报告工件的不同版本


一旦你有了工作并且清楚地知道该做什么-然后试着把所有这些都放到你现有的(旧的)项目中。祝您一切顺利。

非常感谢您的回复@peterThomas。我也成功地得到了黄瓜报告。
<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>Mav_Demo.RunnerFunction</groupId>
<artifactId>RunnerFunction</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>
    <junit.version>4.12</junit.version>
    <cucumber.version>1.2.5</cucumber.version>
    <selenium.version>2.53.0</selenium.version>
    <maven.compiler.version>3.3</maven.compiler.version>
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>
</properties>    

<dependencies> 
    <dependency>
<groupId>com.intuit.karate</groupId>
<artifactId>karate-apache</artifactId>
<version>0.7.0</version>
<scope>test</scope>
</dependency>   
    <dependency>
        <groupId>com.intuit.karate</groupId>
        <artifactId>karate-junit4</artifactId>
        <version>0.7.0</version>
        <scope>test</scope>
    </dependency>
    <dependency>
<groupId>net.masterthought</groupId>
<artifactId>cucumber-reporting</artifactId>
<version>3.8.0</version>
<scope>test</scope>
</dependency>    
    <dependency>
        <groupId>info.cukes</groupId>
        <artifactId>cucumber-java</artifactId>
        <version>${cucumber.version}</version>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>info.cukes</groupId>
        <artifactId>cucumber-core</artifactId>
        <version>${cucumber.version}</version>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>info.cukes</groupId>
        <artifactId>cucumber-junit</artifactId>
        <version>${cucumber.version}</version>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>net.masterthought</groupId>
        <artifactId>cucumber-reporting</artifactId>
        <version>3.7.0</version>
    </dependency>

    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>${junit.version}</version>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-java</artifactId>
        <version>${selenium.version}</version>
        <scope>test</scope>

    </dependency>

    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-chrome-driver</artifactId>
        <version>${selenium.version}</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>
        <includes>
            <include>Mav_demo.RunnerFunction/ExamplesTest.java</include>
        </includes>
        <argLine>-Dfile.encoding=UTF-8</argLine>
    <systemProperties>
        <cucumber.options>--tags ~@ignore</cucumber.options>
    </systemProperties>            
    </configuration>
</plugin>            
    </plugins>        
</build>       
Feature: to print results
Scenario: looping the post method

Given url 'https://www.googleapis.com/geolocation/v1/geolocate'
And param key = 'AIzaSyB2jt4BQ9McqBXAe8dYcp1CwKf0oGFlWuc'
And request 'payload'
When method post
And print response
Then status 200