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 recordThis record models an execution plan created from the requirement given by user.static classA class that models a result of a scene execution. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidafterAll(org.junit.jupiter.api.extension.ExtensionContext executionContext) Executes actions planned for After All stage.voidafterEach(org.junit.jupiter.api.extension.ExtensionContext executionContext) Executes actions planned for After Each stage.voidbeforeAll(org.junit.jupiter.api.extension.ExtensionContext executionContext) Executes actions planned for Before All stage.voidbeforeEach(org.junit.jupiter.api.extension.ExtensionContext executionContext) Executes actions planned for Before Each stage.static voidstatic ExecutionEnvironmentcreateExecutionEnvironment(String testClassName) Creates an execution environment object for a given test class.findMethodByName(String methodName, Class<?> klass) Note that resolution is done based on the value ofNamedannotation first.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 ofTestTemplateInvocationContextobjects.booleansupportsTestTemplate(org.junit.jupiter.api.extension.ExtensionContext extensionContext) Returnstrueto 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) Returnstrueto let the framework know this engine supports test template. Note that test template is pre-defined asrunTestAction(String, Action)method inAutotestRunnerclass and test programmers do not need to defined it by themselves.- Specified by:
supportsTestTemplatein 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 ofTestTemplateInvocationContextobjects.- Specified by:
provideTestTemplateInvocationContextsin 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
TestTemplateInvocationContextobjects.
-
beforeAll
public void beforeAll(org.junit.jupiter.api.extension.ExtensionContext executionContext) throws InvocationTargetException, InstantiationException, IllegalAccessException, NoSuchMethodException Executes actions planned for Before All stage.- Specified by:
beforeAllin interfaceorg.junit.jupiter.api.extension.BeforeAllCallback- Parameters:
executionContext- the current extension context; nevernull- Throws:
InvocationTargetExceptionInstantiationExceptionIllegalAccessExceptionNoSuchMethodException
-
beforeEach
public void beforeEach(org.junit.jupiter.api.extension.ExtensionContext executionContext) Executes actions planned for Before Each stage.- Specified by:
beforeEachin 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:
afterEachin 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:
afterAllin 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.
-
findMethodByName
Note that resolution is done based on the value ofNamedannotation first.- Parameters:
methodName- A name of a method to be found.klass- A class from which a method is searched.- Returns:
- An optional containing a found method, otherwise, empty.
-