Is it possible to generate Cucumber HTML Reports with Karate's JUnit5 fluent API?

user11929337 :

Our team is starting a JUnit 5 project with karate tests.

Currently we are using this as a template for our Karate test runner https://github.com/intuit/karate#junit-5-parallel-execution.

It allows us to pass in the "target/surefire-reports" and then before the test finishes we call ReportBuilder.generateReports(). It is basically identical to this code https://github.com/intuit/karate/blob/b50202b3c8a8916a7db0f3d5196d42086ab80a04/karate-junit4/src/test/java/com/intuit/karate/mock/MockServerTest.java.

This works well, but while I was looking at how to set up JUnit 5 I noticed this very slick fluent api https://github.com/intuit/karate#junit-5.

It would be nice to use that syntax, but I can't get the Cucumber report generated like I can with Runner.parallel. I made sure the maven-surefire-plugin was in build.gradle(although I could have messed that up) but it didn't seem to help.

I also tried doing ReportBuilder.generateReports() and the related logic from the parallel execution example in the @AfterAll function, but couldn't get that working either. The errors suggested that the target/surefire-reports folder didn't exist.

Is the cucumber report supported in the second example? If so, is there a trick to getting it setup?

Peter Thomas :

Great question. The reason we de-couple the JUnit execution and the parallel-runner - is JUnit is more useful in development mode, and you expect detailed pass/fail stats in the IDE for example. But this will be an un-necessary overhead in "CI mode".

That said, we have put in some work on making the Parallel runner a fluent interface, so great timing :) You can find an example on line 57 here.

May I request you to try the develop branch and see if you are missing anything ? Building is easy, here are some instructions: https://github.com/intuit/karate/wiki/Developer-Guide

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=148555&siteId=1