Skip to content

Commit 9d0317b

Browse files
committed
MQE-2270: Pausing of test during a failure is not intuitive for ENABLE_PAUSE=true
1 parent 17a8961 commit 9d0317b

File tree

4 files changed

+39
-3
lines changed

4 files changed

+39
-3
lines changed

src/Magento/FunctionalTestingFramework/Module/MagentoWebDriver.php

+23-2
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,9 @@
5454
class MagentoWebDriver extends WebDriver
5555
{
5656
use AttachmentSupport;
57-
use Pause;
57+
use Pause {
58+
pause as codeceptPause;
59+
}
5860

5961
const MAGENTO_CRON_INTERVAL = 60;
6062
const MAGENTO_CRON_COMMAND = 'cron:run';
@@ -843,7 +845,7 @@ public function _failed(TestInterface $test, $fail)
843845
if ($this->pngReport === null && $this->htmlReport === null) {
844846
$this->saveScreenshot();
845847
if (getenv('ENABLE_PAUSE') === 'true') {
846-
$this->pause();
848+
$this->pause(true);
847849
}
848850
}
849851

@@ -1028,4 +1030,23 @@ public function switchToIFrame($locator = null)
10281030
$this->webDriver->switchTo()->frame($els[0]);
10291031
}
10301032
}
1033+
1034+
/**
1035+
* Invoke Codeption pause()
1036+
*
1037+
* @param boolean $pauseOnFail
1038+
* @return void
1039+
*/
1040+
public function pause($pauseOnFail = false)
1041+
{
1042+
if (!\Codeception\Util\Debug::isEnabled()) {
1043+
return;
1044+
}
1045+
1046+
if ($pauseOnFail) {
1047+
print(PHP_EOL . "Failure encountered. Pausing execution..." . PHP_EOL . PHP_EOL);
1048+
}
1049+
1050+
$this->codeceptPause();
1051+
}
10311052
}

src/Magento/FunctionalTestingFramework/Test/Objects/ActionObject.php

+1
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ class ActionObject
7777
const ACTION_TYPE_COMMENT = 'comment';
7878
const ACTION_TYPE_HELPER = 'helper';
7979
const INVISIBLE_STEP_ACTIONS = ['retrieveEntityField', 'getSecret'];
80+
const PAUSE_ACTION_INTERNAL_ATTRIBUTE = 'pauseOnFail';
8081

8182
/**
8283
* The unique identifier for the action

src/Magento/FunctionalTestingFramework/Test/Util/TestHookObjectExtractor.php

+5-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,11 @@ public function createDefaultFailedHook($parentName)
6666
{
6767
$defaultSteps['saveScreenshot'] = new ActionObject("saveScreenshot", "saveScreenshot", []);
6868
if (getenv('ENABLE_PAUSE') === 'true') {
69-
$defaultSteps['pauseWhenFailed'] = new ActionObject('pauseWhenFailed', 'pause', []);
69+
$defaultSteps['pauseWhenFailed'] = new ActionObject(
70+
'pauseWhenFailed',
71+
'pause',
72+
[ActionObject::PAUSE_ACTION_INTERNAL_ATTRIBUTE => true]
73+
);
7074
}
7175

7276
$hook = new TestHookObject(

src/Magento/FunctionalTestingFramework/Util/TestGenerator.php

+10
Original file line numberDiff line numberDiff line change
@@ -1441,6 +1441,16 @@ public function generateStepsPhp($actionObjects, $generationScope = TestGenerato
14411441

14421442
$testSteps .= $dateGenerateCode;
14431443
break;
1444+
case "pause":
1445+
$pauseAttr = $actionObject->getCustomActionAttributes(
1446+
ActionObject::PAUSE_ACTION_INTERNAL_ATTRIBUTE
1447+
);
1448+
if ($pauseAttr) {
1449+
$testSteps .= sprintf("\t\t$%s->%s(%s);", $actor, $actionObject->getType(), 'true');
1450+
} else {
1451+
$testSteps .= sprintf("\t\t$%s->%s();", $actor, $actionObject->getType());
1452+
}
1453+
break;
14441454
case "comment":
14451455
$input = $input === null ? strtr($value, ['$' => '\$', '{' => '\{', '}' => '\}']) : $input;
14461456
// Combining userInput from native XML comment and <comment/> action to fall-through 'default' case

0 commit comments

Comments
 (0)