Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions dev/tests/verification/Tests/ExtendedGenerationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
*/
namespace tests\verification\Tests;

use Magento\FunctionalTestingFramework\Test\Handlers\TestObjectHandler;
use Magento\FunctionalTestingFramework\Util\TestGenerator;
use tests\util\MftfTestCase;

class ExtendedGenerationTest extends MftfTestCase
Expand Down Expand Up @@ -87,14 +89,23 @@ public function testExtendedTestGenerationRemoveHookAction()
}

/**
* Tests generation of test that attemps to extend a test that doesn't exist
* Tests to ensure extended tests with no parents are not generated
*
* @throws \Exception
* @throws \Magento\FunctionalTestingFramework\Exceptions\TestReferenceException
*/
public function testExtendedTestGenerationNoParent()
{
$this->generateAndCompareTest('ChildExtendedTestNoParent');
$testObject = TestObjectHandler::getInstance()->getObject('ChildExtendedTestNoParent');
$test = TestGenerator::getInstance(null, [$testObject]);
$test->createAllTestFiles();

$cestFile = $test->getExportDir() .
DIRECTORY_SEPARATOR .
$testObject->getCodeceptionName() .
".php";

$this->assertFalse(file_exists($cestFile));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,10 +210,10 @@ public function skipTest($testObject)
$annotations = $testObject->getAnnotations();

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

$skippedTest = new TestObject(
Expand Down
10 changes: 10 additions & 0 deletions src/Magento/FunctionalTestingFramework/Util/TestGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,16 @@ private function assembleAllTestPhp($testManifest, array $testsToIgnore)
$cestPhpArray = [];

foreach ($testObjects as $test) {
// Do not generate test if it is an extended test and parent does not exist
if ($test->isSkipped() && !empty($test->getParentName())) {
try {
TestObjectHandler::getInstance()->getObject($test->getParentName());
} catch (TestReferenceException $e) {
print("{$test->getName()} will not be generated. Parent {$e->getMessage()} \n");
continue;
}
}

$this->debug("<comment>Start creating test: " . $test->getCodeceptionName() . "</comment>");
$php = $this->assembleTestPhp($test);
$cestPhpArray[] = [$test->getCodeceptionName(), $php];
Expand Down