What’s the purpose of karate-junit5 when you can run tests without it?

Great question and I can answer this. You are right, directly using the Runner class is sufficient, and this is the only way to run tests in parallel.

However, if you use the JUnit runner you get the “green bar” experience you are used to as a Java developer and we make sure the IDE UI (e.g the tree-view of tests run and failures etc) is populated. In IntelliJ you even see the logs when you click on one of the “test case” nodes if I remember right.

EDIT: note that I mean here you can see the data of each Scenario in the IDE, not the Java class of the containing JUnit test. Screenshot of IntelliJ below. So this can be convenient to quickly see what failed and the corresponding error message without having to dive into logs / HTML reports:

enter image description here

But once you get used to looking at the HTML reports that Karate outputs, in my opinion – you don’t need the JUnit integration.

To summarize: the JUnit support is

a) because we started as a Cucumber extension (there is even a @KarateOptions annotation that is being deprecated)

b) because some folks like the IDE integration + experience and it is useful to run “one test at a time” in dev-mode

Your comment makes me more convinced that we can eventually deprecate the JUnit support. Would be good to get your feedback on this once you have had a chance to play around more.

Leave a Comment