Class LightkeeperExtension

java.lang.Object
nl.pim16aap2.lightkeeper.framework.LightkeeperExtension
All Implemented Interfaces:
org.junit.jupiter.api.extension.AfterAllCallback, org.junit.jupiter.api.extension.AfterEachCallback, org.junit.jupiter.api.extension.BeforeAllCallback, org.junit.jupiter.api.extension.BeforeEachCallback, org.junit.jupiter.api.extension.Extension, org.junit.jupiter.api.extension.ParameterResolver, org.junit.jupiter.api.extension.TestInstantiationAwareExtension

public final class LightkeeperExtension extends Object implements org.junit.jupiter.api.extension.BeforeAllCallback, org.junit.jupiter.api.extension.BeforeEachCallback, org.junit.jupiter.api.extension.AfterEachCallback, org.junit.jupiter.api.extension.AfterAllCallback, org.junit.jupiter.api.extension.ParameterResolver
JUnit extension for framework lifecycle management.

On test failure the extension writes a diagnostics bundle (test outcome, captured server errors, server console output) before any cleanup runs — see FailureDiagnosticsWriter. Two system properties control this: lightkeeper.diagnostics (on-failure (default) | always | off) and lightkeeper.diagnosticsDirectory (default target/lightkeeper-reports, resolved against the test JVM's working directory).

  • Nested Class Summary

    Nested classes/interfaces inherited from interface org.junit.jupiter.api.extension.TestInstantiationAwareExtension

    org.junit.jupiter.api.extension.TestInstantiationAwareExtension.ExtensionContextScope
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    afterAll(org.junit.jupiter.api.extension.ExtensionContext context)
    Closes shared framework state after all tests in the class.
    void
    afterEach(org.junit.jupiter.api.extension.ExtensionContext context)
    Cleans up method-scoped framework resources after each test method.
    void
    beforeAll(org.junit.jupiter.api.extension.ExtensionContext context)
    Starts a shared framework when tests are not configured for per-method fresh servers.
    void
    beforeEach(org.junit.jupiter.api.extension.ExtensionContext context)
    Starts or scopes framework state before each test method.
    resolveParameter(org.junit.jupiter.api.extension.ParameterContext parameterContext, org.junit.jupiter.api.extension.ExtensionContext extensionContext)
    Resolves an active framework instance for parameter injection.
    boolean
    supportsParameter(org.junit.jupiter.api.extension.ParameterContext parameterContext, org.junit.jupiter.api.extension.ExtensionContext extensionContext)
    Supports injection of ILightkeeperFramework parameters.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.junit.jupiter.api.extension.TestInstantiationAwareExtension

    getTestInstantiationExtensionContextScope
  • Constructor Details

    • LightkeeperExtension

      public LightkeeperExtension()
  • Method Details

    • beforeAll

      public void beforeAll(org.junit.jupiter.api.extension.ExtensionContext context)
      Starts a shared framework when tests are not configured for per-method fresh servers.

      Also validates the diagnostics configuration up front: a typo in lightkeeper.diagnostics must fail loudly here, before any server is provisioned — not during cleanup.

      Specified by:
      beforeAll in interface org.junit.jupiter.api.extension.BeforeAllCallback
    • beforeEach

      public void beforeEach(org.junit.jupiter.api.extension.ExtensionContext context)
      Starts or scopes framework state before each test method.
      Specified by:
      beforeEach in interface org.junit.jupiter.api.extension.BeforeEachCallback
    • afterEach

      public void afterEach(org.junit.jupiter.api.extension.ExtensionContext context)
      Cleans up method-scoped framework resources after each test method.

      Diagnostics are captured first: JUnit's TestWatcher hooks only run after all afterEach callbacks, by which point the framework is closed (fresh mode) or its error capture cleared (shared mode) — so this is the last moment the failing test's state is still observable.

      Specified by:
      afterEach in interface org.junit.jupiter.api.extension.AfterEachCallback
    • afterAll

      public void afterAll(org.junit.jupiter.api.extension.ExtensionContext context)
      Closes shared framework state after all tests in the class.
      Specified by:
      afterAll in interface org.junit.jupiter.api.extension.AfterAllCallback
    • supportsParameter

      public boolean supportsParameter(org.junit.jupiter.api.extension.ParameterContext parameterContext, org.junit.jupiter.api.extension.ExtensionContext extensionContext) throws org.junit.jupiter.api.extension.ParameterResolutionException
      Supports injection of ILightkeeperFramework parameters.
      Specified by:
      supportsParameter in interface org.junit.jupiter.api.extension.ParameterResolver
      Throws:
      org.junit.jupiter.api.extension.ParameterResolutionException
    • resolveParameter

      public Object resolveParameter(org.junit.jupiter.api.extension.ParameterContext parameterContext, org.junit.jupiter.api.extension.ExtensionContext extensionContext) throws org.junit.jupiter.api.extension.ParameterResolutionException
      Resolves an active framework instance for parameter injection.
      Specified by:
      resolveParameter in interface org.junit.jupiter.api.extension.ParameterResolver
      Throws:
      org.junit.jupiter.api.extension.ParameterResolutionException