Class ConfigurableScenarioTest<C extends dev.aherscu.qa.testing.utils.config.AbstractConfiguration<? extends org.apache.commons.configuration.Configuration>,​T extends AnyScenarioType,​GIVEN extends GenericFixtures<T,​?> & ScenarioType<T>,​WHEN extends GenericActions<T,​?> & ScenarioType<T>,​THEN extends GenericVerifications<T,​?> & ScenarioType<T>>

  • Type Parameters:
    C - type of configuration used by scenario
    T - type of scenario
    GIVEN - the fixtures stage
    WHEN - the actions stage
    THEN - the verifications stage
    Direct Known Subclasses:
    AbstractWireMockTest

    @ThreadSafe
    public abstract class ConfigurableScenarioTest<C extends dev.aherscu.qa.testing.utils.config.AbstractConfiguration<? extends org.apache.commons.configuration.Configuration>,​T extends AnyScenarioType,​GIVEN extends GenericFixtures<T,​?> & ScenarioType<T>,​WHEN extends GenericActions<T,​?> & ScenarioType<T>,​THEN extends GenericVerifications<T,​?> & ScenarioType<T>>
    extends TypedScenarioTest<T,​GIVEN,​WHEN,​THEN>
    Enables Apache Configuration on JGiven/TestNG tests.
    Author:
    aherscu
    • Field Detail

      • INTERNAL_DATA_PROVIDER

        public static final String INTERNAL_DATA_PROVIDER
        The internal data provider name.
        See Also:
        Constant Field Values
      • concurrency

        public static final AtomicInteger concurrency
        Concurrency achieved so far.
      • issuedRandomIds

        public static final Set<String> issuedRandomIds
        List of generated random identifiers.
      • USE_FIRST_PARAM

        protected static final String USE_FIRST_PARAM
        The first parameter to be used with CaseAs annotation.
        See Also:
        Constant Field Values
      • configurationType

        protected final Class<C extends dev.aherscu.qa.testing.utils.config.AbstractConfiguration<? extends org.apache.commons.configuration.Configuration>> configurationType
        The configuration type of this scenario.
      • startTime

        protected final ThreadLocal<Instant> startTime
        Start time of execution thread.
    • Constructor Detail

      • ConfigurableScenarioTest

        protected ConfigurableScenarioTest​(Class<C> configurationType)
        Initializes the configuration type of this scenario by "configuration-sources.xml".
        Parameters:
        configurationType - type of configuration
    • Method Detail

      • afterMethodKeepJenkinsAlive

        @AfterMethod(alwaysRun=true)
        protected final void afterMethodKeepJenkinsAlive​(Method testMethod)
        When running repeated tests in Jenkins we must write something into the console otherwise connection is lost.
        Parameters:
        testMethod - The test method, not null
      • beforeClassInitializeSession

        @BeforeClass(alwaysRun=true)
        protected final void beforeClassInitializeSession()

        Renames current thread as <class-simple-name>, as returned by Class.getSimpleName(). This means that code running in BeforeClass or BeforeTest annotated methods will have its thread named such this.

      • beforeMethodInitializeSession

        @BeforeMethod(alwaysRun=true)
        protected final void beforeMethodInitializeSession​(Method testMethod,
                                                           Object[] parameters)

        If the randomId for current thread was not already set, then generates one and sets it. The generated random id is URL-friendly. Thread starting time is stored in startTime.

        In addition, renames current thread as <class-simple-name>:<method-name>:<hash-of-params>@<thread-id>, where:

        class-simple-name
        as returned by Class.getSimpleName()
        method-name
        as returned by Method.getName()
        class-simple-name
        hex string of whatever is returned by Arrays.hashCode(Object[]), wherein Object[] is the parameters of the test method
        thread-id
        identifier of thread as of Thread.getId()
        This means code running in Test annotated methods will have its thread named such this.

        Parameters:
        testMethod - The test method, not null
        parameters - the parameters used to invoke this test method instance
      • configuration

        protected C configuration()
        On first call initializes the configuration for this scenario type and caches it; on further calls will return the cached configuration.
        Returns:
        the configuration for this type
        Throws:
        RuntimeException - if the configuration type cannot be instantiated or the "configuration-sources.xml" refer to a non-existing resource.
      • generateRandomId

        protected String generateRandomId()
        Generates a Base64, URL-friendly, encoding of a random UUID. It is called once per thread initialization.

        Override to provide different behavior.

        Returns:
        random identifier to be used during the entire test session
      • randomId

        protected final String randomId()
        Returns:
        a random string; by default, initialized before each method.