- Behave - Discussion
- Behave - Useful Resources
- Behave - Quick Guide
- Behave - Debugging
- Behave - Hooks
- Behave - Reports
- Behave - Retry Mechanism
- Behave - Exclude Tests
- Behave - Runner Script
- Behave - Step Parameters
- Behave - Step Functions
- Behave - Multi-Methods
- Behave - Optional Part
- Behave - Regular Expressions
- Behave - Step Matchers
- Behave - Enumeration
- Behave - Tags
- Behave - Data Types
- Behave - Background
- Behave - Steps in a Step
- Behave - Setup Table
- Behave - Multiline Text
- Behave - Scenario Outlines
- Behave - Step Parameters
- Behave - Supported Languages
- Behave - First Steps
- Behave - Step Implementations
- Behave - Feature Files
- Behave - Gherkin Keywords
- Behave - Feature Testing Setup
- Behave - Configuration Files
- Behave - Command Line
- Behave - Installation
- Behave - Introduction
- Behave - Home
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
Behave - Step Parameters
We can have parameters within the step names. These parameters can be taken care of by the regular expressions or by the default or extended parser with the help of the use_step_matcher method.
behave.use_step_matcher(name)
Modify the parameter matcher in parsing the step text. There are multiple in-built parsers present in Behave, as explained below −
parse − It gives an easy parser that restores regular expression for the step parameters with plain syntax. For example, {parameter: type}. It allows type conversion with type converters.
cfparse − It has the Cardinapty Field (CF) support. By default, it generates the missing type converters for connected cardinapty (if type converter for cardinapty equal to one is given). It can support the below parse expressions −
{values:Type+} – Cardinapty=1..N, many
{values:Type*} – Cardinapty=0..N, many0
{values:Type?} – Cardinapty=0..1, optional
It allows type conversion with type converters.
re − It utipses the complete regular expressions to parse the clause. We have to take the help of the named groups (? P<name>…) to declare variables obtained from the text and then feed it to the step ().
We can have our customised matcher along with new data types with the help of the register_type method.
behave.register_type(w)
Registers a user defined type for parsing during type conversion at the time of step matching.
class behave.matchers.Matcher(func, pattern ,step_type=None)
It extracts the parameters out of step names.
pattern − The pattern matching associated with the step function.
func − The step function is the pattern is associated with.
check_match(step) − To match with the step name provided.
describe(schema=None) − Give description in form of text of the function or matcher object.
regex_pattern: Yields the utipsed textual regex expression.
class behave.model_core.Argument(start, end, original, value, name=Name)
An argument for a step name in the feature file obtained with step decorator parameters.
The attributes are as follows −
original − The original text which is matched in the name of the step.
value − The value of the argument which is type converted.
name − The argument name. The value is set to None, if the parameter is not given.
start − The starting index of the argument in step name.
end − The ending index of the argument in step name.
class behave.matchers.Match(func, arguments=None)
A step in the feature file which is parameter-matched and obtained with step decorator parameters.
The attributes are as follows −
func − The step function which is apppcable to the given match.
arguments − The argument pst the instances having the matched parameter obtained from the name of the step.