Home > Back-end >  Allure Report with karate 1.0.1 generating report with just one test case
Allure Report with karate 1.0.1 generating report with just one test case

Time:05-10

I am working on a maven project where I am creating both cucumber reports and allure reports with karate 1.0.1 via jenkins. But even though the detailed cucumber reports are getting generated, I am getting only one test case in the allure report

My TestParallelRunner.java file:

@CucumberOptions(plugin = {"pretty" , "html:target/cucumber-html-reports", "io.qameta.allure.cucumber4jvm.AllureCucumber5Jvm","json:target/cucumber/cucumber.json"})
//@KarateOptions(tags = "~@ignore")
public class TestParallelRunner {
    
    @Test
    public void testParallel() {
        
        //String outputDir = "target//surefire-reports";
        Builder testRun = new Builder();
        testRun.path("classpath:com/api/automation/Features").outputCucumberJson(true).tags("~@ignore");
        Results results = testRun.parallel(3);
        generateReport(results.getReportDir());

        
       Assertions.assertEquals(0, results.getFailCount(), "There are some Failed Scenarios");
        

    }
    
    public static void generateReport(String reportDirLocation) {
        File reportDir=new File(reportDirLocation);     
        Collection<File> jsonFiles = FileUtils.listFiles(reportDir, new String[] {"json"}, true);
        //jsonFiles.add(File("cucumber-report.json"));
        List<String> jsonPaths = new ArrayList<>();
        
        //jsonFiles.add("cucumber-report-2.json");
        jsonFiles.forEach(file -> jsonPaths.add(file.getAbsolutePath()));
        Configuration config = new Configuration(new File("target"), "Cucumber Report");
        ReportBuilder reportBuilder = new ReportBuilder(jsonPaths, config);
        reportBuilder.generateReports();
        
        }

}

My pom.xml file:

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <java.version>11</java.version>
        <maven.compiler.version>3.8.1</maven.compiler.version>
        <maven.surefire.version>2.22.2</maven.surefire.version>        
        <karate.version>1.0.1</karate.version>
        <allure.maven.version>2.11.2</allure.maven.version>
        <allure-junit5.version>2.17.3</allure-junit5.version>
    </properties>    

    <dependencies>         
        <dependency>
            <groupId>com.intuit.karate</groupId>
            <artifactId>karate-junit5</artifactId>
            <version>${karate.version}</version>
            <scope>test</scope>
        </dependency>       
        
        <!-- https://mvnrepository.com/artifact/net.masterthought/cucumber-reporting -->
<dependency>
    <groupId>net.masterthought</groupId>
    <artifactId>cucumber-reporting</artifactId>
    <version>5.6.1</version>
    <scope>test</scope>
</dependency> 

<!-- https://mvnrepository.com/artifact/io.qameta.allure/allure-maven -->
<dependency>
    <groupId>io.qameta.allure</groupId>
    <artifactId>allure-maven</artifactId>
    <version>${allure.maven.version}</version>
</dependency>

<!-- https://mvnrepository.com/artifact/io.qameta.allure/allure-cucumber5-jvm -->
<dependency>
    <groupId>io.qameta.allure</groupId>
    <artifactId>allure-cucumber5-jvm</artifactId>
    <version>2.17.3</version>
</dependency>

<!-- https://mvnrepository.com/artifact/io.qameta.allure/allure-junit5 -->
<dependency>
    <groupId>io.qameta.allure</groupId>
    <artifactId>allure-junit5</artifactId>
    <version>${allure-junit5.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-compiler-plugin</artifactId>
                <version>${maven.compiler.version}</version>
                <configuration>
                    <encoding>UTF-8</encoding>
                    <source>${java.version}</source>
                    <target>${java.version}</target>
                    <compilerArgument>-Werror</compilerArgument>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>${maven.surefire.version}</version>
                <executions>
                <execution>
                 <goals>
                 <goal>test</goal>
                 </goals>
                 </execution>
                </executions>
                <configuration>
                    <useSystemClassLoader>false</useSystemClassLoader>
                    <testFailureIgnore>true</testFailureIgnore>
                    <systemProperties>
                    <property>
                    <name>allure.results.directory</name>
                    <value> ${project.build.directory}/allure-results</value>
                    </property>
                    </systemProperties>
                </configuration>
            </plugin>
          </plugins>        
    </build>       
   </project> 

My Allure reports in my jenkins pipeline:

allure([
          includeProperties: false, 
          jdk: '',
          properties:[],
          reportBuildPolicy:'ALWAYS', 
          results: [[path: '/allure-results']]
       ]
       )

But my the json file created in my allure-results folder contains only the following entry:

{"uuid":"XXXXXXX-XXXXX-XXXXXX","historyId":"XXXXXXXXXXXXXXXXXX","testCaseId":"[engine:junit-jupiter]/[class:com.api.automation.TestParallelRunner]/[method:testParallel()]","testCaseName":"testParallel()","fullName":"com.api.automation.TestParallelRunner.testParallel","labels":[{"name":"junit.platform.uniqueid","value":"[engine:junit-jupiter]/[class:com.api.automation.TestParallelRunner]/[method:testParallel()]"},{"name":"host","value":"XXXXXX"},{"name":"thread","value":"XXXXXXX.main(1)"},{"name":"framework","value":"junit-platform"},{"name":"language","value":"java"},{"name":"package","value":"com.api.automation.TestParallelRunner"},{"name":"testClass","value":"com.api.automation.TestParallelRunner"},{"name":"testMethod","value":"testParallel"},{"name":"suite","value":"com.api.automation.TestParallelRunner"}],"links":[],"name":"testParallel()","status":"passed","stage":"finished","description":"","steps":[],"attachments":[],"parameters":[],"start":1652145767274,"stop":1652145775326}

Thus not getting a complete test execution picture the way cucumber report is showing :

enter image description here

CodePudding user response:

A few points:

  • Related