scenario.scenariorunner module¶
Scenario execution management.
- SCENARIO_RUNNER¶
Main instance of
ScenarioRunner.
- class ScenarioRunner¶
Bases:
LoggerTest execution engine: runs scenarios, i.e. instances derived from the
ScenarioDefinitionclass.Only one instance, accessible through the
SCENARIO_RUNNERsingleton.Implements the
main()function for scenario executions.This class works with the following helper classes, with their respected purpose:
ScenarioArgs: command line arguments,ScenarioExecution: object that describes a scenario execution,ScenarioStack: stack ofScenarioExecution,ScenarioLogging: scenario execution logging,ScenarioReport: scenario report generation.
- class ExecutionMode¶
Bases:
StrEnumExecution mode enum.
Tells whether the scenario runner is currently:
building the objects,
generating the documentation,
or executing the test.
- BUILD_OBJECTS = 'build'¶
The scenario runner is currently building the test objects.
- DOC_ONLY = 'doc-only'¶
The scenario runner is currently generating the test documentation.
- EXECUTE = 'execute'¶
The scenario runner is currently executing the final test script.
- __init__()¶
Sets up logging for the
ScenarioRunnerclass, and member variables.
- main()¶
Scenario runner main function, as a member method.
- Returns:
Error code.
- property _execution_mode¶
Current execution mode.
Depends on 1) the scenario stack building context, and 2) the scenario args –doc-only option.
- executepath(scenario_path)¶
Executes a scenario from its script path.
- Parameters:
scenario_path – Scenario Python script path.
- Returns:
Error code, but no
errcodes.ErrorCode.TEST_ERROR.
Feeds the
SCENARIO_RESULTSinstance.
- executescenario(scenario_definition, start_time=None)¶
Executes a scenario or subscenario.
- Parameters:
scenario_definition – Scenario to execute.
start_time –
Optional starting time specification.
May be set in order to save the most accurate info on the starting time of the scenario.
- Returns:
Error code, but no
errcodes.ErrorCode.TEST_ERROR.
- _buildscenario(scenario_definition)¶
Builds a scenario definition.
- Parameters:
scenario_definition –
ScenarioDefinitioninstance to populate with steps, actions and expected results definitions.- Returns:
Error code.
- _beginscenario(scenario_definition)¶
Begins a scenario or sub-scenario execution.
- Parameters:
scenario_definition – Scenario or subscenario which execution to start.
- Returns:
Error code.
- _endscenario(scenario_definition)¶
Ends a scenario or subscenario execution.
- Parameters:
scenario_definition – Scenario or subscenario which execution to end.
- Returns:
Error code.
- _execstep(step_definition)¶
Executes the step.
- Parameters:
step_definition – Step definition to execute.
- onstepdescription(description)¶
Call redirection from
scenariodefinition.ScenarioDefinition.STEP().- Parameters:
description – Step description.
- _notifyknownissuedefinitions(step_user_api, known_issues=None)¶
Notifies the known issues declared at the definition level for the given scenario or step definition.
- Parameters:
step_user_api – Scenario or step definition to process known issues for.
known_issues – Specific known issue list to process. Defaults to
StepUserApi.known_issueswhen not set.
- onactionresult(action_result_type, description)¶
Call redirection from
scenariodefinition.ScenarioDefinition.ACTION()orscenariodefinition.ScenarioDefinition.RESULT().- Parameters:
action_result_type – ACTION or RESULT.
description – Action or expected result description.
- _endcurrentactionresult()¶
Ends the current action or expected result section.
- onevidence(evidence)¶
Call redirection from
scenariodefinition.ScenarioDefinition.EVIDENCE().- Parameters:
evidence – Evidence text.
- doexecute()¶
Tells whether the test script shall be executed.
- Returns:
Truewhen the test script shall be executed.
- onerror(error, originator=None)¶
Called when an error occurs.
- Parameters:
error – Error that occurred.
originator – Scenario or step definition that made the call to
onerror(), set in :meth:.stepuserapi.StepUserApi.knownissue()`..
- _shouldstop()¶
Tells whether the scenario execution should stop.
- Returns:
Truewhen the scenario execution should stop,Falsewhen the scenario execution should continue on.
- goto(to_step_specification)¶
Call redirection from
scenariodefinition.ScenarioDefinition.goto().- Parameters:
to_step_specification – Specification of the next step to execute.
- exception GotoException¶
Bases:
ExceptionBreaks execution in a step method when
scenariodefinition.ScenarioDefinition.goto()is called.