Search code examples
karate

Summary HTML Report not generated when path is specified in terms of classpath in Karate


I am trying to run some test cases using Karate v1.2.0 (with Junit5). Everything is working well, except for a minor discrepancy that seems to be occurring during report generation. The project folder structure is something like this

my-project/
├── src/
│   └── test/
│       └── java/
│           ├── ronan/
│           │   ├── api/
│           │   │   ├── ApiTest.java
│           │   │   ├── feature-1.feature
│           │   │   └── feature-2.feature
│           │   └── util/
│           │       └── SomeUtil.java
│           ├── karate-config.js
│           └── logback-test.xml
└── build.gradle

When my ApiTest.java specifies the path by individual feature file names, the individual feature HTML reports and the summary HTML report are generated.

@Karate.Test
Karate testAPI() {
    // Generates individual HTML reports as well as the summary HTML report
    return Karate.run("feature-1", "feature-2")
            .outputJunitXml(true)
            .relativeTo(getClass()); 
}

However, when I specify the path using classpath:, only the individual feature HTML reports are generated and not the summary report.

@Karate.Test
Karate testAPI() {
    // Generates ONLY individual reports
    return Karate.run("classpath:ronan/api")
            .outputJunitXml(true)
            .relativeTo(getClass()); 
}

The test task is configured in build.gradle as below

test {
    useJUnitPlatform()
    systemProperty "karate.options", System.properties.getProperty("karate.options")
    systemProperty "karate.env", System.properties.getProperty("karate.env")
    outputs.upToDateWhen { false }
}

I wasn't able to find any relevant documentation or SO answers related to the same, so I'm not sure if this is expected and if I'm doing something wrong or if it's an issue with report generation.

Any help on this would be greatly appreciated. Thanks!


Solution

  • For CI, please use the Runner API, and only then can you run tests in parallel. The JUnit helpers are just for IDE dev-loop convenience.

    Please read this for details: https://stackoverflow.com/a/65578167/143475

    Now if you still see issues with the Runner, then open an issue with a way to replicate. Meanwhile you are welcome to contribute code to fix the problem you describe in your question.