Skip to content

Commit

Permalink
macro adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
judit-nahaj committed Nov 28, 2017
1 parent ed42cbf commit e294ff2
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ compiler.save('./features/dist/login.feature', ast, {

* [Replacer](lib/builtIn/Replacer.md) - Replaces keywords in the feature files.
* [ScenarioOutlineNumbering](lib/builtIn/ScenarioOutlineNumbering.md) - Makes all scenario, generated from scenario outlines unique.
* [ScenarioOutlineNumbering](lib/builtIn/Macro.md) - Enables the user to create and execute macros.

## CLI

Expand Down
19 changes: 11 additions & 8 deletions lib/builtIn/Macro.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
# Macro for Gherkin precompiler

This Macro is responsible for defining macros in feature files and then
using them
This pre-processor is responsible for defining macros in feature files and then executing them.

To use it a @macro(${macroName}) tag must be added to a scenario. This
scenario will not run on its own, it is only for defining the macro.
In another scenario when a step "macro ${macroName} is executed" is used
the steps of the macro with the same name will be executed.

Restrictions: Macro definition scenario cannot contain a macro executing
step.
Usage:
1. Defining a macro by creating macro scenario. Using @macro(${macroName}) tag on the scenario defines a macro with the provided name and steps that are included.

Note: this scenario will not be run during test execution, it is removed during pre-processing. The definition cannot contain macro execution step (see next step).

Errors are thrown when no name or steps are included in the definition, or when defining a macro with an already existing name.

2. Executing the macro. In another scenario using step 'macro ${macroName} is executed' will replace this step with the steps in the definition of ${macroName} macro.

Throws error when no ${macroName} is provided in the step, or when no macro is defined by name provided.

See examples for the input files and an output in the test/data folder.
1 change: 1 addition & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,6 @@ API.save = (pathToFile, ast, options) => {
API.builtIn = {};
API.builtIn.Replacer = require('./builtIn/Replacer');
API.builtIn.ScenarioOutlineNumbering = require('./builtIn/ScenarioOutlineNumbering');
API.builtIn.Macro = require('./builtIn/Macro');

module.exports = API;

0 comments on commit e294ff2

Please sign in to comment.