-
Notifications
You must be signed in to change notification settings - Fork 1
Parameters
Handow provide built-in general steps for common testing requirements. A story will instantiate steps in a scenario to perform the definite testing operations. The way to instantiate a step is passing parameters to it. Handow can accept parameters in different ways:
- Scenario scope parameters - defined directly in the scenarion with @parameters: [] tag
- Story scope parameters - the scenario parameters of the 'Given' scenario (the 1st scenario) with story scope
- Stage scope parameters - defined in stages of a plan
- Global scope parameters - defined in parameter files availble to whole project
The priority order of the different scoped parameters in upper list is form high to low. The higher priority parameters can override the lower if they have same parameter name.
Except populating steps arguments, parameters can also be refered by running control, e.g., refered by @skip() evaluation on scenarios and steps.
The scenario parameters are optionally declared under any 'When' step, and the only purpose is populating the steps arguments in current scenario with highest priority.
@scenario: Person age validation
@skip: (this.Person_Private)
When I enter {value: "Age_Value"} to {selector: "Age_Input"}
Then I can see {selector: "Validate_Error"} presented @skip: (this.Hide_Message)
@parameters: [
{
Age_Value: 17,
Age_Input: "#form-input-age",
Validate_Error: "#age-validation"
},
{
Age_Value: 69,
Age_Input: "#form-input-age",
Validate_Error: "#age-validation"
}
]
The scenario parameters should be primitive data type like boolean, number and string. For Object type parameters, they must be declared in global parameter files.
The prototype step label looks like this, e.g.,
When I enter {value} to {selector}
Developes need to attach parameters to the scenario and pass the parameter keys to step arguments.
The parameters in the 'Given' scanario are special. They have the story scope availabe to all scenarios in current story - except they are overridden in a 'When' scenario.
The parameters is an array of objects. The scenario will be iterated by parameters in run time. So a scenario is looping muti-times if its parameters length more than 1. As for the 'Given' scenario, its parameters will loop whole story instead of that 'Given' scenario.
Investigate the form_1.feature and its test report in a Live Demo
The parameters are also refered by the condition expression in @skip: ( Expression ).
- @skip: ( Expression ) can only refer parameters in parent scopes. That means the @skip on scenario cannot access current Scenario parameters, but the @skips on a step can access all available parameters of current scenario.
- The condition expression must be Boolean computed with Arithmatic, Compare or Logic operators.
- You cannot skip a story, cannot skip all 'When' steps or all 'Then' steps in a scenario.
Refer Design Test Plan to see parameters in stage object.
Some parameters will be reused by multiple stories, or not primitive data type, e.g., a XHR object. We can declare these parameters in .params.js files available to all stories to keep them tidy. There could be multiple parameter files defined under params/ folder. The global parameters could be overridden by parameters decleared in stages, storis and scenarios.
Users can browse all global parameters by the right panel of the Edit dashboard in SHM UI.
Supported by Handow team [email protected]