Class StreamingTestIterator

java.lang.Object
io.karatelabs.junit6.StreamingTestIterator
All Implemented Interfaces:
Iterator<org.junit.jupiter.api.DynamicNode>

public class StreamingTestIterator extends Object implements Iterator<org.junit.jupiter.api.DynamicNode>
A blocking iterator that yields DynamicNode instances as Karate scenarios complete.

This iterator bridges the gap between Karate's streaming execution model and JUnit's @TestFactory pattern. The iterator blocks on hasNext() until test events arrive from the Karate execution thread, enabling true streaming test discovery.

Supports two modes:

  • Flat mode: Each scenario becomes a top-level DynamicTest
  • Hierarchical mode: Features become DynamicContainers containing scenario tests
  • Constructor Details

    • StreamingTestIterator

      public StreamingTestIterator(BlockingQueue<TestEvent> eventQueue, boolean hierarchical)
      Creates a new streaming iterator with default timeout.
      Parameters:
      eventQueue - the queue to consume events from
      hierarchical - if true, group scenarios under feature containers
    • StreamingTestIterator

      public StreamingTestIterator(BlockingQueue<TestEvent> eventQueue, boolean hierarchical, long timeoutMinutes)
      Creates a new streaming iterator with custom timeout.
      Parameters:
      eventQueue - the queue to consume events from
      hierarchical - if true, group scenarios under feature containers
      timeoutMinutes - maximum time to wait for next event
  • Method Details

    • hasNext

      public boolean hasNext()
      Specified by:
      hasNext in interface Iterator<org.junit.jupiter.api.DynamicNode>
    • next

      public org.junit.jupiter.api.DynamicNode next()
      Specified by:
      next in interface Iterator<org.junit.jupiter.api.DynamicNode>
    • stream

      public Stream<org.junit.jupiter.api.DynamicNode> stream()
      Returns this iterator as a Stream for use with @TestFactory.
      Returns:
      a sequential stream of dynamic nodes