Class ThreadLocalTestContextHolder

java.lang.Object
io.trino.tempto.context.ThreadLocalTestContextHolder

public final class ThreadLocalTestContextHolder extends Object
Static helper for holding TestContext stack in a thread local variable.

Justification for existence:

Using thread local for holding current TestContext is less explicit and a bit hacky. But allows for having less verbose test building blocks.

We also do not require users to subclass a common context-aware test class when they write tests.

  • Method Details

    • testContext

      public static TestContext testContext()
    • testContextIfSet

      public static Optional<TestContext> testContextIfSet()
    • pushTestContext

      public static void pushTestContext(TestContext testContext)
    • popTestContext

      public static TestContext popTestContext()
    • pushAllTestContexts

      public static void pushAllTestContexts(TestContextStack<? extends TestContext> testContextStack)
    • popAllTestContexts

      public static TestContextStack<TestContext> popAllTestContexts()
    • assertTestContextNotSet

      public static void assertTestContextNotSet()
    • assertTestContextSet

      public static void assertTestContextSet()