Skip to content

Commit d5cb6dc

Browse files
authored
Merge pull request #1063 from ferranrecio/MDL-81885-main
[docs] Improve generator tool using behat - MDL-81885
2 parents 161f1d7 + 9130e74 commit d5cb6dc

File tree

1 file changed

+25
-9
lines changed

1 file changed

+25
-9
lines changed

general/development/tools/generator.md

+25-9
Original file line numberDiff line numberDiff line change
@@ -44,23 +44,39 @@ Before executing the behat generators, you need a `feature` file you want to exe
4444

4545
The tool does not use `selenium` or any other browser wrapper. It reads the feature file and executes specific steps in it.
4646

47+
This means:
48+
49+
1. The tool will only execute a few steps, which are generators and set config values. If any other type of step is present in the `feature` file, it will show a parsing error.
50+
1. For now, the tool can only execute normal scenarios. It does not support background, or outline scenarios.
51+
4752
:::
4853

49-
This means:
54+
:::tip Example
5055

51-
1. The tool will only execute generator steps. If any other type of step is present in the `feature` file, it will show a parsing error.
52-
1. For now, the tool can only execute normal scenarios. It does not support background, outline, or scenario outline scenarios.
56+
Some example Behat generator files can be found in [`admin/tool/generator/tests/fixtures/`](https://github.com/moodle/moodle/blob/main/admin/tool/generator/tests/fixtures/). For instance, [`testscenario/scenario.feature`](https://github.com/moodle/moodle/blob/main/admin/tool/generator/tests/fixtures/testscenario/scenario.feature) creates a course with two assignment activities and enrols one teacher along with five students.
57+
58+
:::
5359

54-
To execute the behat generators via the web interface, go to `Site administration > Development > Create testing scenarios`. Once there, you can upload the `feature` file you want to execute and see the the execution results.
60+
### Execute a testing scenario behat file
5561

56-
To execute the behat generators via CLI, you can use the following command:
62+
Before running a testing scenario, you need to install all behat dependencies. If you already execute some behat on the instance you can skip this step. Otherwise, you need to install the dependencies by running the following command:
5763

5864
```bash
59-
php admin/tool/generator/cli/runtestscenario.php --feature=/path/to/some/testing/scenario.feature
65+
php admin/tool/generator/cli/runtestscenario.php
6066
```
6167

62-
:::tip Example
68+
There are two ways to run a testing scenario using a behat file: via the web interface or the CLI.
6369

64-
Some example Behat generator files can be found in [`admin/tool/generator/tests/fixtures/`](https://github.com/moodle/moodle/blob/main/admin/tool/generator/tests/fixtures/). For instance, [`testscenario/scenario.feature`](https://github.com/moodle/moodle/blob/main/admin/tool/generator/tests/fixtures/testscenario/scenario.feature) creates a course with two assignment activities and enrols one teacher along with five students.
70+
To run via web interface:
6571

66-
:::
72+
1. Go to `Site administration > Development > Create testing scenarios`.
73+
1. Upload the `feature` file you want to execute and submit the form.
74+
75+
To run via CLI:
76+
77+
1. Copy the `feature` file you want to execute to some server location. You will need the full path to the file.
78+
1. Run the following command:
79+
80+
```bash
81+
php admin/tool/generator/cli/runtestscenario.php --feature=/path/to/some/testing/scenario.feature
82+
```

0 commit comments

Comments
 (0)