Skip to content

Commit 1c4f1dd

Browse files
Ashish.Kumar18Ashish.Kumar18
authored andcommitted
ACQE-4318: seprate function
1 parent e7b5ee4 commit 1c4f1dd

File tree

1 file changed

+24
-6
lines changed

1 file changed

+24
-6
lines changed

src/Magento/FunctionalTestingFramework/Suite/SuiteGenerator.php

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,28 @@ public function generateSuite($suiteName)
139139
$this->generateSuiteFromTest($suiteName, []);
140140
}
141141

142+
/**
143+
* Function which generate Testgroupmembership file.
144+
*
145+
* @param array $tests
146+
* @return void
147+
* @throws \Exception
148+
*/
149+
public function generateTestgroupmembership($tests)
150+
{
151+
$memberShipFilePath = FilePathFormatter::format(TESTS_MODULE_PATH).'_generated/testgroupmembership.txt';
152+
static $suiteCount = 0;
153+
foreach ($tests as $key => $testName) {
154+
try {
155+
$suiteTests = $suiteCount.":".$key.":".$suiteName.':'.$testName."\n";
156+
file_put_contents($memberShipFilePath, $suiteTests, FILE_APPEND);
157+
} catch (FastFailException $e) {
158+
throw $e;
159+
}
160+
}
161+
$suiteCount++;
162+
}
163+
142164
/**
143165
* Function which takes a suite name and a set of test names. The function then generates all relevant supporting
144166
* files and classes for the suite. The function takes an optional argument for suites which are split by a parallel
@@ -157,17 +179,14 @@ private function generateSuiteFromTest($suiteName, $tests = [], $originalSuiteNa
157179
$relativePath = TestGenerator::GENERATED_DIR . DIRECTORY_SEPARATOR . $suiteName;
158180
$fullPath = FilePathFormatter::format(TESTS_MODULE_PATH) . $relativePath . DIRECTORY_SEPARATOR;
159181
DirSetupUtil::createGroupDir($fullPath);
160-
$memberShipFilePath = FilePathFormatter::format(TESTS_MODULE_PATH).'_generated/testgroupmembership.txt';
161-
static $suiteCount = 0;
162182
$exceptionCollector = new ExceptionCollector();
163183
try {
164184
$relevantTests = [];
165185
if (!empty($tests)) {
166186
$this->validateTestsReferencedInSuite($suiteName, $tests, $originalSuiteName);
167-
foreach ($tests as $key => $testName) {
187+
$this->generateTestgroupmembership($tests);
188+
foreach ($tests as $testName) {
168189
try {
169-
$suiteTests = $suiteCount.":".$key.":".$suiteName.':'.$testName."\n";
170-
file_put_contents($memberShipFilePath, $suiteTests, FILE_APPEND);
171190
$relevantTests[$testName] = TestObjectHandler::getInstance()->getObject($testName);
172191
} catch (FastFailException $e) {
173192
throw $e;
@@ -181,7 +200,6 @@ private function generateSuiteFromTest($suiteName, $tests = [], $originalSuiteNa
181200
} else {
182201
$relevantTests = SuiteObjectHandler::getInstance()->getObject($suiteName)->getTests();
183202
}
184-
$suiteCount++;
185203
if (empty($relevantTests)) {
186204
$exceptionCollector->reset();
187205
// There are suites that include no test on purpose for certain Magento edition.

0 commit comments

Comments
 (0)