diff --git a/src/Magento/FunctionalTestingFramework/Suite/Util/SuiteObjectExtractor.php b/src/Magento/FunctionalTestingFramework/Suite/Util/SuiteObjectExtractor.php index 4ff0b25a3..4db1abfc7 100644 --- a/src/Magento/FunctionalTestingFramework/Suite/Util/SuiteObjectExtractor.php +++ b/src/Magento/FunctionalTestingFramework/Suite/Util/SuiteObjectExtractor.php @@ -40,6 +40,8 @@ public function __construct() * @param array $parsedSuiteData * @return array * @throws XmlException + * @SuppressWarnings(PHPMD.CyclomaticComplexity) + * @SuppressWarnings(PHPMD.NPathComplexity) */ public function parseSuiteDataIntoObjects($parsedSuiteData) { @@ -65,6 +67,19 @@ public function parseSuiteDataIntoObjects($parsedSuiteData) $suiteHooks = []; + //Check for collisions between suite name and existing group name + $suiteName = $parsedSuite[self::NAME]; + $testGroupConflicts = TestObjectHandler::getInstance()->getTestsByGroup($suiteName); + if (!empty($testGroupConflicts)) { + $testGroupConflictsFileNames = ""; + foreach ($testGroupConflicts as $test) { + $testGroupConflictsFileNames .= $test->getFilename() . "\n"; + } + $exceptionmessage = "\"Suite names and Group names can not have the same value. \t\n" . + "Suite: \"{$suiteName}\" also exists as a group annotation in: \n{$testGroupConflictsFileNames}"; + throw new XmlException($exceptionmessage); + } + //extract include and exclude references $groupTestsToInclude = $parsedSuite[self::INCLUDE_TAG_NAME] ?? []; $groupTestsToExclude = $parsedSuite[self::EXCLUDE_TAG_NAME] ?? []; diff --git a/src/Magento/FunctionalTestingFramework/Test/Objects/TestObject.php b/src/Magento/FunctionalTestingFramework/Test/Objects/TestObject.php index 70a138d35..818e87924 100644 --- a/src/Magento/FunctionalTestingFramework/Test/Objects/TestObject.php +++ b/src/Magento/FunctionalTestingFramework/Test/Objects/TestObject.php @@ -43,6 +43,13 @@ class TestObject */ private $hooks = []; + /** + * String of filename of test + * + * @var String + */ + private $filename; + /** * TestObject constructor. * @@ -50,13 +57,15 @@ class TestObject * @param ActionObject[] $parsedSteps * @param array $annotations * @param TestHookObject[] $hooks + * @param String $filename */ - public function __construct($name, $parsedSteps, $annotations, $hooks) + public function __construct($name, $parsedSteps, $annotations, $hooks, $filename = null) { $this->name = $name; $this->parsedSteps = $parsedSteps; $this->annotations = $annotations; $this->hooks = $hooks; + $this->filename = $filename; } /** @@ -69,6 +78,16 @@ public function getName() return $this->name; } + /** + * Getter for the Test Filename + * + * @return string + */ + public function getFilename() + { + return $this->filename; + } + /** * Getter for Codeception format name *