Skip to content

Commit ba061e6

Browse files
authored
MQE-1161: Extended Tests With No Parents Are Skipped (#204)
* MQE-1161: Extended Tests With No Parents Are Skipped - Tests are not generated if they are skipped - Modified verification test to reflect change * MQE-1161: Extended Tests With No Parents Are Skipped - Updated skip flagging to use new skip annotation * MQE-1161: Extended Tests With No Parents Are Skipped - Updated conditional to check for parent test existence - Added console information in addition to the log * MQE-1161: Extended Tests With No Parents Are Skipped - Updated message to be more explicit
1 parent 19effcc commit ba061e6

File tree

3 files changed

+27
-6
lines changed

3 files changed

+27
-6
lines changed

dev/tests/verification/Tests/ExtendedGenerationTest.php

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
*/
66
namespace tests\verification\Tests;
77

8+
use Magento\FunctionalTestingFramework\Test\Handlers\TestObjectHandler;
9+
use Magento\FunctionalTestingFramework\Util\TestGenerator;
810
use tests\util\MftfTestCase;
911

1012
class ExtendedGenerationTest extends MftfTestCase
@@ -87,14 +89,23 @@ public function testExtendedTestGenerationRemoveHookAction()
8789
}
8890

8991
/**
90-
* Tests generation of test that attemps to extend a test that doesn't exist
92+
* Tests to ensure extended tests with no parents are not generated
9193
*
9294
* @throws \Exception
9395
* @throws \Magento\FunctionalTestingFramework\Exceptions\TestReferenceException
9496
*/
9597
public function testExtendedTestGenerationNoParent()
9698
{
97-
$this->generateAndCompareTest('ChildExtendedTestNoParent');
99+
$testObject = TestObjectHandler::getInstance()->getObject('ChildExtendedTestNoParent');
100+
$test = TestGenerator::getInstance(null, [$testObject]);
101+
$test->createAllTestFiles();
102+
103+
$cestFile = $test->getExportDir() .
104+
DIRECTORY_SEPARATOR .
105+
$testObject->getCodeceptionName() .
106+
".php";
107+
108+
$this->assertFalse(file_exists($cestFile));
98109
}
99110

100111
/**

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -210,10 +210,10 @@ public function skipTest($testObject)
210210
$annotations = $testObject->getAnnotations();
211211

212212
// Add skip to the group array if it doesn't already exist
213-
if (array_key_exists('group', $annotations) && !in_array('skip', $annotations['group'])) {
214-
array_push($annotations['group'], 'skip');
215-
} elseif (!array_key_exists('group', $annotations)) {
216-
$annotations['group'] = ['skip'];
213+
if (array_key_exists('skip', $annotations)) {
214+
return $testObject;
215+
} elseif (!array_key_exists('skip', $annotations)) {
216+
$annotations['skip'] = ['issueId' => "ParentTestDoesNotExist"];
217217
}
218218

219219
$skippedTest = new TestObject(

src/Magento/FunctionalTestingFramework/Util/TestGenerator.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,16 @@ private function assembleAllTestPhp($testManifest, array $testsToIgnore)
244244
$cestPhpArray = [];
245245

246246
foreach ($testObjects as $test) {
247+
// Do not generate test if it is an extended test and parent does not exist
248+
if ($test->isSkipped() && !empty($test->getParentName())) {
249+
try {
250+
TestObjectHandler::getInstance()->getObject($test->getParentName());
251+
} catch (TestReferenceException $e) {
252+
print("{$test->getName()} will not be generated. Parent {$e->getMessage()} \n");
253+
continue;
254+
}
255+
}
256+
247257
$this->debug("<comment>Start creating test: " . $test->getCodeceptionName() . "</comment>");
248258
$php = $this->assembleTestPhp($test);
249259
$cestPhpArray[] = [$test->getCodeceptionName(), $php];

0 commit comments

Comments
 (0)