Skip to content

Commit fe3da36

Browse files
committed
MQE-2110: MFTF command to pause test execution
1 parent 4487ff5 commit fe3da36

File tree

5 files changed

+88
-5
lines changed

5 files changed

+88
-5
lines changed

docs/commands/mftf.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -559,6 +559,31 @@ To upgrade all test components inside the `Catalog` module:
559559
vendor/bin/mftf upgrade:tests /Users/user/magento2/app/code/Magento/Catalog/Test/Mftf/
560560
```
561561

562+
### `codecept:run`
563+
564+
MFTF wrapper command invokes `vendor/bin/codecept run`. This command runs tests in functional suite. It does not generate tests for you. You must do that first.
565+
566+
#### Usage
567+
568+
See https://codeception.com/docs/reference/Commands#Run
569+
570+
```bash
571+
vendor/bin/mftf codecept:run [<suite|test>] --[<option(s)>]
572+
```
573+
574+
#### Examples
575+
576+
```bash
577+
# Run all tests in functional suite
578+
vendor/bin/mftf codecept:run functional
579+
# Run all tests in functional suite with options
580+
vendor/bin/mftf codecept:run functional --verbose --steps --debug
581+
# Run one test
582+
vendor/bin/mftf codecept:run functional Magento/_generated/default/AdminLoginSuccessfulTestCest
583+
# Run all tests in default group
584+
vendor/bin/mftf codecept:run functional --verbose --steps -g default
585+
```
586+
562587
<!-- LINK DEFINITIONS -->
563588

564589
[configuration]: ../configuration.md

docs/interactive-pause.md

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Interactive Pause
2+
3+
It’s hard to write a complete test at once. You will need to try different commands with different arguments before you find a correct path.
4+
5+
Since Codeception 3.0 you can pause execution in any point and enter interactive shell where you will be able to try commands in action.
6+
7+
Now this `Interactive Pause` feature is available in MFTF and all you need to do is to set `ENABLE_PAUSE=true` in `.env`.
8+
9+
Check it out at [Codeception website][] for documentation and a video to see `Interactive Pause` in action.
10+
11+
In short, when a test gets to `$I->pause()` step, it stops and shows a console where you can try all available commands with auto-completion, stash commands, and save screenshot, etc.
12+
13+
## Generation Time
14+
15+
A `<pause>` action in xml will always be generated into php regardless if `ENABLE_PAUSE=true` is set or not.
16+
However, when `ENABLE_PAUSE=true` is set, an additional`pause()` action will be generated in `_failed()` hook for a test,
17+
so that the test could pause on failure at run time.
18+
19+
## Execution Time
20+
21+
To use `Interactive Pause` at run time, there are two types of MFTF commands to use.
22+
23+
### MFTF Run Commands
24+
25+
When `ENABLE_PAUSE=true` is set, the following MFTF run commands support `Interactive Pause`.
26+
27+
```bash
28+
vendor/bin/mftf run:group
29+
```
30+
31+
```bash
32+
vendor/bin/mftf run:test
33+
```
34+
35+
```bash
36+
vendor/bin/mftf run:manifest
37+
```
38+
39+
```bash
40+
vendor/bin/mftf run:failed
41+
```
42+
43+
<div class="bs-callout-warning">
44+
Note: MFTF run command's `--debug` option is different from Codeception `--debug` mode option.
45+
</div>
46+
47+
### MFTF Codecept Run Command
48+
49+
You can also use MFTF's wrapper command to run Codeception directly and activate `Interactive Pause` by passing `--debug` option.
50+
You don't need to set `ENABLE_PAUSE=true` for this command.
51+
52+
```bash
53+
vendor/bin/mftf codecept:run --debug
54+
```
55+
56+
## References
57+
58+
[Codeception website](https://codeception.com/docs/02-GettingStarted#Interactive-Pause)

src/Magento/FunctionalTestingFramework/Console/BaseGenerateCommand.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -255,14 +255,14 @@ protected function pauseEnabled()
255255
/**
256256
* Runs the bin/mftf codecept:run command and returns exit code
257257
*
258-
* @param string $command
258+
* @param string $commandStr
259259
* @param OutputInterface $output
260260
* @return integer
261261
* @throws \Exception
262262
*/
263-
protected function codeceptRunTest(string $command, OutputInterface $output)
263+
protected function codeceptRunTest(string $commandStr, OutputInterface $output)
264264
{
265-
$input = new StringInput($command);
265+
$input = new StringInput($commandStr);
266266
$command = $this->getApplication()->find(self::CODECEPT_RUN);
267267
return $command->run($input, $output);
268268
}

src/Magento/FunctionalTestingFramework/Console/CodeceptRunCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ protected function configure()
2424
{
2525
$this->setName('codecept:run')
2626
->setDescription(
27-
"Wrapper command to codecept:run. See https://codeception.com/docs/reference/Commands"
27+
"Wrapper command to vendor/bin/codecept:run. See https://codeception.com/docs/reference/Commands#Run"
2828
);
2929

3030
parent::configure();

src/Magento/FunctionalTestingFramework/Console/RunManifestCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ private function runManifestLine(string $manifestLine, OutputInterface $output)
112112
{
113113
if (getenv('ENABLE_PAUSE') === 'true') {
114114
$codeceptionCommand = BaseGenerateCommand::CODECEPT_RUN_FUNCTIONAL
115-
. '--verbose --steps --debug' . $manifestLine;
115+
. '--verbose --steps --debug ' . $manifestLine;
116116
$input = new StringInput($codeceptionCommand);
117117
$command = $this->getApplication()->find('codecept:run');
118118
$subReturnCode = $command->run($input, $output);

0 commit comments

Comments
 (0)