1

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!

ronan696
  • 13
  • 3

1 Answers1

0

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.

Peter Thomas
  • 54,465
  • 21
  • 84
  • 248
  • 1
    Thanks for the prompt reply! This issue does not occur with the `Runner` API. In fact, I had been using it initially. However, for my use case, I require the tests to "fail fast" (using fail-fast option in Gradle) i.e. the test suite execution should terminate if any scenario fails. This didn't seem to be feasible with the `Runner` API. So as I workaround, I used the mentioned approach. I will probably research some more on achieving fail-fast behaviour. – ronan696 Aug 03 '22 at 07:46