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:
- beforeAll: Every scene in this step is executed in the order they are shown in the execution plan.
- 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.
- 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 tomain
. - 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.
- 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:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final record
This record models an execution plan created from the requirement given by user.static class
A class that models a result of a scene execution. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
afterAll
(org.junit.jupiter.api.extension.ExtensionContext executionContext) Executes actions planned for After All stage.void
afterEach
(org.junit.jupiter.api.extension.ExtensionContext executionContext) Executes actions planned for After Each stage.void
beforeAll
(org.junit.jupiter.api.extension.ExtensionContext extensionContext) Executes actions planned for Before All stage.void
beforeEach
(org.junit.jupiter.api.extension.ExtensionContext executionContext) Executes actions planned for Before Each stage.static void
static ExecutionEnvironment
createExecutionEnvironment
(String testClassName) Creates an execution environment object for a given test class.performActionEntry
(String key, Consumer<List<String>> consumer) Stream
<org.junit.jupiter.api.extension.TestTemplateInvocationContext> provideTestTemplateInvocationContexts
(org.junit.jupiter.api.extension.ExtensionContext extensionContext) Returns a stream ofTestTemplateInvocationContext
objects.boolean
supportsTestTemplate
(org.junit.jupiter.api.extension.ExtensionContext extensionContext) Returnstrue
to let the framework know this engine supports test template.
-
Constructor Details
-
AutotestEngine
public AutotestEngine()
-
-
Method Details
-
supportsTestTemplate
public boolean supportsTestTemplate(org.junit.jupiter.api.extension.ExtensionContext extensionContext) Returnstrue
to let the framework know this engine supports test template. Note that test template is pre-defined asrunTestAction(String, Action)
method inAutotestRunner
class and test programmers do not need to defined it by themselves.- Specified by:
supportsTestTemplate
in interfaceorg.junit.jupiter.api.extension.TestTemplateInvocationContextProvider
- Parameters:
extensionContext
- the extension context for the test template method about to be invoked; nevernull
- Returns:
true
.
-
provideTestTemplateInvocationContexts
public Stream<org.junit.jupiter.api.extension.TestTemplateInvocationContext> provideTestTemplateInvocationContexts(org.junit.jupiter.api.extension.ExtensionContext extensionContext) Returns a stream ofTestTemplateInvocationContext
objects.- Specified by:
provideTestTemplateInvocationContexts
in interfaceorg.junit.jupiter.api.extension.TestTemplateInvocationContextProvider
- Parameters:
extensionContext
- the extension context for the test template method about to be invoked; nevernull
- 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 interfaceorg.junit.jupiter.api.extension.BeforeAllCallback
- Parameters:
extensionContext
- the current extension context; nevernull
- 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 interfaceorg.junit.jupiter.api.extension.BeforeEachCallback
- Parameters:
executionContext
- the current extension context; nevernull
-
afterEach
public void afterEach(org.junit.jupiter.api.extension.ExtensionContext executionContext) Executes actions planned for After Each stage.- Specified by:
afterEach
in interfaceorg.junit.jupiter.api.extension.AfterEachCallback
- Parameters:
executionContext
- the current extension context; nevernull
-
afterAll
public void afterAll(org.junit.jupiter.api.extension.ExtensionContext executionContext) Executes actions planned for After All stage.- Specified by:
afterAll
in interfaceorg.junit.jupiter.api.extension.AfterAllCallback
- Parameters:
executionContext
- the current extension context; nevernull
-
configureLoggingForSessionLevel
public static void configureLoggingForSessionLevel() -
performActionEntry
public static AutotestEngine.SceneExecutionResult performActionEntry(String key, Consumer<List<String>> consumer) -
createExecutionEnvironment
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.
-