From 34956406e94cb244f6aa5c6ad37badba55aeb67d Mon Sep 17 00:00:00 2001 From: Kevin Kozan Date: Thu, 19 Dec 2019 09:51:06 -0600 Subject: [PATCH 1/3] MQE-1911: --allow-skipped removing test hooks - Fixed conditional - Modified existing conditional to follow same pattern --- .../Util/TestGenerator.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php b/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php index dc6aa9238..09c353029 100644 --- a/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php +++ b/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php @@ -242,7 +242,7 @@ public function assembleTestPhp($testObject) $className = $testObject->getCodeceptionName(); try { - if (!$testObject->isSkipped() && !MftfApplicationConfig::getConfig()->allowSkipped()) { + if (!$testObject->isSkipped() || MftfApplicationConfig::getConfig()->allowSkipped()) { $hookPhp = $this->generateHooksPhp($testObject->getHooks()); } else { $hookPhp = null; @@ -1601,7 +1601,13 @@ private function generateTestPhp($test) $testName = str_replace(' ', '', $testName); $testAnnotations = $this->generateAnnotationsPhp($test->getAnnotations(), true); $dependencies = 'AcceptanceTester $I'; - if ($test->isSkipped() && !MftfApplicationConfig::getConfig()->allowSkipped()) { + if (!$test->isSkipped() || MftfApplicationConfig::getConfig()->allowSkipped()) { + try { + $steps = $this->generateStepsPhp($test->getOrderedActions()); + } catch (\Exception $e) { + throw new TestReferenceException($e->getMessage() . " in Test \"" . $test->getName() . "\""); + } + } else { $skipString = "This test is skipped due to the following issues:\\n"; $issues = $test->getAnnotations()['skip'] ?? null; if (isset($issues)) { @@ -1611,12 +1617,6 @@ private function generateTestPhp($test) } $steps = "\t\t" . '$scenario->skip("' . $skipString . '");' . "\n"; $dependencies .= ', \Codeception\Scenario $scenario'; - } else { - try { - $steps = $this->generateStepsPhp($test->getOrderedActions()); - } catch (\Exception $e) { - throw new TestReferenceException($e->getMessage() . " in Test \"" . $test->getName() . "\""); - } } $testPhp .= $testAnnotations; From 04ef38e2390ec07a4414ed86056433cb363104f7 Mon Sep 17 00:00:00 2001 From: Kevin Kozan Date: Thu, 19 Dec 2019 12:28:49 -0600 Subject: [PATCH 2/3] MQE-1911: --allow-skipped removing test hooks - Unit test --- .../FunctionalTestFramework/Util/TestGeneratorTest.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/dev/tests/unit/Magento/FunctionalTestFramework/Util/TestGeneratorTest.php b/dev/tests/unit/Magento/FunctionalTestFramework/Util/TestGeneratorTest.php index cadc1c6a8..f25153513 100644 --- a/dev/tests/unit/Magento/FunctionalTestFramework/Util/TestGeneratorTest.php +++ b/dev/tests/unit/Magento/FunctionalTestFramework/Util/TestGeneratorTest.php @@ -9,6 +9,7 @@ use AspectMock\Test as AspectMock; use Magento\FunctionalTestingFramework\Test\Objects\ActionObject; +use Magento\FunctionalTestingFramework\Test\Objects\TestHookObject; use Magento\FunctionalTestingFramework\Test\Objects\TestObject; use Magento\FunctionalTestingFramework\Util\MagentoTestCase; use Magento\FunctionalTestingFramework\Util\TestGenerator; @@ -76,14 +77,20 @@ public function testAllowSkipped() $actionObject = new ActionObject('fakeAction', 'comment', [ 'userInput' => $actionInput ]); + $beforeActionInput = 'beforeInput'; + $beforeActionObject = new ActionObject('beforeAction', 'comment', [ + 'userInput' => $beforeActionInput + ]); $annotations = ['skip' => ['issue']]; - $testObject = new TestObject("sampleTest", ["merge123" => $actionObject], $annotations, [], "filename"); + $beforeHook = new TestHookObject("before", "sampleTest", ['beforeAction' => $beforeActionObject]); + $testObject = new TestObject("sampleTest", ["fakeAction" => $actionObject], $annotations, ["before" => $beforeHook], "filename"); $testGeneratorObject = TestGenerator::getInstance("", ["sampleTest" => $testObject]); $output = $testGeneratorObject->assembleTestPhp($testObject); $this->assertNotContains('This test is skipped', $output); $this->assertContains($actionInput, $output); + $this->assertContains($beforeActionInput, $output); } } From 60a07a3113cb3b4e73f2f8ee81f2416075b4f87b Mon Sep 17 00:00:00 2001 From: Kevin Kozan Date: Thu, 19 Dec 2019 12:40:06 -0600 Subject: [PATCH 3/3] MQE-1911: --allow-skipped removing test hooks - static check fix --- .../FunctionalTestFramework/Util/TestGeneratorTest.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/dev/tests/unit/Magento/FunctionalTestFramework/Util/TestGeneratorTest.php b/dev/tests/unit/Magento/FunctionalTestFramework/Util/TestGeneratorTest.php index f25153513..8f8eee749 100644 --- a/dev/tests/unit/Magento/FunctionalTestFramework/Util/TestGeneratorTest.php +++ b/dev/tests/unit/Magento/FunctionalTestFramework/Util/TestGeneratorTest.php @@ -84,7 +84,13 @@ public function testAllowSkipped() $annotations = ['skip' => ['issue']]; $beforeHook = new TestHookObject("before", "sampleTest", ['beforeAction' => $beforeActionObject]); - $testObject = new TestObject("sampleTest", ["fakeAction" => $actionObject], $annotations, ["before" => $beforeHook], "filename"); + $testObject = new TestObject( + "sampleTest", + ["fakeAction" => $actionObject], + $annotations, + ["before" => $beforeHook], + "filename" + ); $testGeneratorObject = TestGenerator::getInstance("", ["sampleTest" => $testObject]); $output = $testGeneratorObject->assembleTestPhp($testObject);