Class AutotestEngine

java.lang.Object
jp.co.moneyforward.autotest.framework.testengine.AutotestEngine
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.TestTemplateInvocationContextProvider

public class AutotestEngine extends Object implements org.junit.jupiter.api.extension.BeforeAllCallback, org.junit.jupiter.api.extension.BeforeEachCallback, org.junit.jupiter.api.extension.TestTemplateInvocationContextProvider, org.junit.jupiter.api.extension.AfterEachCallback, org.junit.jupiter.api.extension.AfterAllCallback

The test execution engine of the insdog.

In the implementation of this engine, the steps performed during a test class execution are following:

  1. beforeAll: Every scene in this step is executed in the order they are shown in the execution plan.
  2. beforeEach: For each scene in the value (main) step, every scene in this step is executed in the order. When a failure occurs, the rest will not be executed.
  3. value (or main): This step is the main part of the entire test. This stage was named value to make the user test scenario class as simple as possible. (In Java, in order to omit typing an annotation's method name, we need to name it value) In the future, we may change it to main.
  4. afterEach: Scenes in this step are executed in the provided order, after each value (or main) scene is performed even if on a failure. In this step, even if a failure happens in an afterEach scene, the subsequent scenes should still be executed.
  5. afterAll: Scenes in this step are executed in the provided order, after all the scenes in the afterEach for the last of the value (or main) is executed. In this step, even if a failure happens in an afterAll scene, the subsequent scenes should still be executed.

Note that the "execution plan" and which scenes a user specifies to execute are not the same. The former is modeled by ExecutionPlan and the latter is modeled by the AutotestExecution.Spec. The PlanningStrategy instance interprets the AutotestExecution.Spec and creates an ExecutionPlan. The discussion above is about the ExecutionPlan.

Also, a PlanningStrategy should be designed in a way where scenes that a user specifies explicitly are included in its resulting execution plan.

With this separation, insdog allows users to specify scenes that really want to execute directly.

See Also:
  • Constructor Details

    • AutotestEngine

      public AutotestEngine()
  • Method Details

    • supportsTestTemplate

      public boolean supportsTestTemplate(org.junit.jupiter.api.extension.ExtensionContext extensionContext)
      Returns true to let the framework know this engine supports test template. Note that test template is pre-defined as runTestAction(String, Action) method in AutotestRunner class and test programmers do not need to defined it by themselves.
      Specified by:
      supportsTestTemplate in interface org.junit.jupiter.api.extension.TestTemplateInvocationContextProvider
      Parameters:
      extensionContext - the extension context for the test template method about to be invoked; never null
      Returns:
      true.
    • provideTestTemplateInvocationContexts

      public Stream<org.junit.jupiter.api.extension.TestTemplateInvocationContext> provideTestTemplateInvocationContexts(org.junit.jupiter.api.extension.ExtensionContext extensionContext)
      Returns a stream of TestTemplateInvocationContext objects.
      Specified by:
      provideTestTemplateInvocationContexts in interface org.junit.jupiter.api.extension.TestTemplateInvocationContextProvider
      Parameters:
      extensionContext - the extension context for the test template method about to be invoked; never null
      Returns:
      A stream of TestTemplateInvocationContext objects.
    • beforeAll

      public void beforeAll(org.junit.jupiter.api.extension.ExtensionContext extensionContext) throws InvocationTargetException, InstantiationException, IllegalAccessException, NoSuchMethodException
      Executes actions planned for Before All stage.
      Specified by:
      beforeAll in interface org.junit.jupiter.api.extension.BeforeAllCallback
      Parameters:
      extensionContext - the current extension context; never null
      Throws:
      InvocationTargetException
      InstantiationException
      IllegalAccessException
      NoSuchMethodException
    • beforeEach

      public void beforeEach(org.junit.jupiter.api.extension.ExtensionContext executionContext)
      Executes actions planned for Before Each stage.
      Specified by:
      beforeEach in interface org.junit.jupiter.api.extension.BeforeEachCallback
      Parameters:
      executionContext - the current extension context; never null
    • afterEach

      public void afterEach(org.junit.jupiter.api.extension.ExtensionContext executionContext)
      Executes actions planned for After Each stage.
      Specified by:
      afterEach in interface org.junit.jupiter.api.extension.AfterEachCallback
      Parameters:
      executionContext - the current extension context; never null
    • afterAll

      public void afterAll(org.junit.jupiter.api.extension.ExtensionContext executionContext)
      Executes actions planned for After All stage.
      Specified by:
      afterAll in interface org.junit.jupiter.api.extension.AfterAllCallback
      Parameters:
      executionContext - the current extension context; never null
    • configureLoggingForSessionLevel

      public static void configureLoggingForSessionLevel()
    • performActionEntry

      public static AutotestEngine.SceneExecutionResult performActionEntry(String key, Consumer<List<String>> consumer)
    • createExecutionEnvironment

      public static ExecutionEnvironment createExecutionEnvironment(String testClassName)
      Creates an execution environment object for a given test class.
      Parameters:
      testClassName - A test class name for which an execution environment is created.
      Returns:
      An execution environment object.