Class TestEventRecorder

java.lang.Object
com.gtnewhorizons.horizonqa.internal.TestEventRecorder
All Implemented Interfaces:
EventLog

public final class TestEventRecorder extends Object implements EventLog
Per-test ordered log of TestEvents. One instance lives on every GameTestInstance.

Recording is globally toggled by the horizonqa.events system property: passing -Dhorizonqa.events=off makes record(java.util.function.Supplier<? extends com.gtnewhorizons.horizonqa.api.event.TestEvent>) an unconditional no-op that does not even invoke the supplier — no record allocation, no payload computation.

Single-thread by construction: a test instance ticks on the server thread, and time-warp re-entry happens on the same thread. No synchronization.

  • Constructor Details

    • TestEventRecorder

      public TestEventRecorder()
  • Method Details

    • record

      public void record(Supplier<? extends TestEvent> factory)
      Emit an event. The supplier is only invoked when recording is enabled and the per-test cap is not yet reached, so callers can build complex payloads inside a lambda without paying the cost when the recorder is disabled.
    • snapshot

      public List<TestEvent> snapshot()
      Unmodifiable view of the recorded events in emit order.
      Specified by:
      snapshot in interface EventLog
    • clock

      public TestClock clock()
    • isEnabled

      public static boolean isEnabled()