2
votes

I'm facing issues in generating a report using Karate framework. I had referred links https://github.com/intuit/karate/blob/master/karate-demo/src/test/java/demo/DemoTestParallel.java https://github.com/intuit/karate#parallel-execution https://github.com/intuit/karate/tree/master/karate-demo#example-report And did exactly the same as given, but still I'm facing issues in generating the report. Please find the below project details. POM.xml

<dependencies>
        <dependency>
            <groupId>com.intuit.karate</groupId>
            <artifactId>karate-apache</artifactId>
            <version>0.9.5</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.intuit.karate</groupId>
            <artifactId>karate-junit4</artifactId>
            <version>0.9.5</version>
            <scope>test</scope>
        </dependency>
         <dependency>
            <groupId>net.masterthought</groupId>
            <artifactId>cucumber-reporting</artifactId>
            <version>5.1.1</version>
            <scope>test</scope>
        </dependency> 
    </dependencies>

Test Runner

public class TestRunner {

    @Test
    public void testParallel() {
        Results results = Runner.path("classpath:testapis").tags("@test").parallel(5);
        generateReport(results.getReportDir());
        assertTrue(results.getErrorMessages(), results.getFailCount() == 0);        
    }

    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();        
    }

}

Project Folder settings enter image description here

Feature file

@test
Feature: Title of your feature
  I want to use this template for my feature file


  Scenario: Title of your scenario
    * url "https://jsonplaceholder.typicode.com"
    Given path "todos/1"
    When method GET
    Then status 200

I'm just executing as mvn clean test

and getting the below error message in console

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running testapis.TestRunner
23:24:41.844 [main] INFO com.intuit.karate.Runner - waiting for parallel features to complete ...
Karate version: 0.9.5
======================================================
elapsed:   0.06 | threads:    5 | thread time: 0.00 
features:     0 | ignored:    0 | efficiency: 0.00
scenarios:    0 | passed:     0 | failed: 0
======================================================

Feb 23, 2020 11:24:42 PM net.masterthought.cucumber.ReportBuilder generateErrorPage
INFO: Unexpected error
net.masterthought.cucumber.ValidationException: None report file was added!
    at net.masterthought.cucumber.ReportParser.parseJsonFiles(ReportParser.java:58)
    at net.masterthought.cucumber.ReportBuilder.generateReports(ReportBuilder.java:88)
    at testapis.TestRunner.generateReport(TestRunner.java:34)
    at testapis.TestRunner.testParallel(TestRunner.java:24)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)

There were 0 features executed but as per the instruction given I did I beleive.

Can someone please help me in resolving this.

1

1 Answers

0
votes

This is normal if there were 0 tests executed, the 3rd party cucumber-reporting library will throw this error.

It looks like your pom.xml does not set the resources correctly: https://github.com/intuit/karate#folder-structure

If you are still stuck, follow this process: https://github.com/intuit/karate/wiki/How-to-Submit-an-Issue