Package io.karatelabs.junit6
Class JUnitBridgeListener
java.lang.Object
io.karatelabs.junit6.JUnitBridgeListener
- All Implemented Interfaces:
io.karatelabs.output.ResultListener
Bridges Karate execution events to JUnit's dynamic test tree via a blocking queue.
Implements ResultListener to receive streaming events from Karate execution
and converts them to TestEvent records that are consumed by
StreamingTestIterator on the JUnit thread.
Supports two modes:
- Flat mode: All scenarios appear at the root level
- Hierarchical mode: Features as containers with scenario children
-
Constructor Summary
ConstructorsConstructorDescriptionJUnitBridgeListener(BlockingQueue<TestEvent> eventQueue, boolean hierarchical) Creates a new bridge listener. -
Method Summary
Modifier and TypeMethodDescriptionvoidcomplete(io.karatelabs.core.SuiteResult result) Signals that the suite has fully finished, terminating the stream.voidonFeatureEnd(io.karatelabs.core.FeatureResult result) voidonFeatureStart(io.karatelabs.gherkin.Feature feature) voidonScenarioEnd(io.karatelabs.core.ScenarioResult result) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.karatelabs.output.ResultListener
onScenarioStart, onSuiteEnd, onSuiteStart
-
Constructor Details
-
JUnitBridgeListener
Creates a new bridge listener.- Parameters:
eventQueue- the queue to publish events tohierarchical- if true, emit FeatureStart/FeatureEnd events for container nesting
-
-
Method Details
-
onFeatureStart
public void onFeatureStart(io.karatelabs.gherkin.Feature feature) - Specified by:
onFeatureStartin interfaceio.karatelabs.output.ResultListener
-
onFeatureEnd
public void onFeatureEnd(io.karatelabs.core.FeatureResult result) - Specified by:
onFeatureEndin interfaceio.karatelabs.output.ResultListener
-
onScenarioEnd
public void onScenarioEnd(io.karatelabs.core.ScenarioResult result) - Specified by:
onScenarioEndin interfaceio.karatelabs.output.ResultListener
-
complete
public void complete(io.karatelabs.core.SuiteResult result) Signals that the suite has fully finished, terminating the stream.Deliberately not driven by
ResultListener.onSuiteEnd(SuiteResult): that callback fires while the suite is still running its listener chain, so report writers (JUnit XML, Cucumber JSON) registered after this bridge may not have flushed their asynchronous per-feature writes yet. Emitting the terminal event from here — invoked only onceRunner.Builder.parallel(...)has fully returned — guarantees that when the JUnit@TestFactorystream completes, all report files are on disk.- Parameters:
result- the suite result (may be null if execution failed before completing)
-