Class TestSetupUtils


  • public final class TestSetupUtils
    extends java.lang.Object
    Guicey TestEnvironmentSetup test utilities.
    Since:
    13.05.2022
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  TestSetupUtils.ClosableWrapper
      Wrapper class for AutoCloseable objects to grant automatic closing inside junit store.
    • Method Detail

      • lookup

        public static TestEnvironmentSetup[] lookup()
        Returns:
        environment setup objects from service lookup
      • create

        @SafeVarargs
        public static java.util.List<TestEnvironmentSetup> create​(java.lang.Class<? extends TestEnvironmentSetup>... extensions)
        Instantiates provided support objects.
        Parameters:
        extensions - extension classes to instantiate
        Returns:
        extension instances
      • executeSetup

        public static void executeSetup​(ExtensionConfig config,
                                        org.junit.jupiter.api.extension.ExtensionContext context,
                                        ListenersSupport listeners)
        Execute all configured support objects. If object returns closable then register it in junit storage for automatic closing.
        Parameters:
        config - extension config
        context - junit extension context
        listeners - listeners support
      • getContextTestName

        public static java.lang.String getContextTestName​(org.junit.jupiter.api.extension.ExtensionContext context)
        Use display names, so would correctly show spock test name or junit test with @DisplayName.
        Parameters:
        context - junit context
        Returns:
        context string (test name of beforeAll and test + method for beforeEach)