Skip to content

Commit af9708a

Browse files
authored
Merge pull request #239 from magento-gl/3.11.0-RC
ACQE-4111 : Including Fatal error when running generate:tests --config parallel -g in 3.11.0 Release
2 parents 53d13c0 + fdc7de9 commit af9708a

File tree

3 files changed

+47
-0
lines changed

3 files changed

+47
-0
lines changed

Diff for: CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Magento Functional Testing Framework Changelog
1212

1313
* Fixed incorrect MFTF test dependencies path
1414
* Removed PHP 7.3 build check from MFTF PR build as PHP 7.3 is no longer supported
15+
* Fixed fatal error when running generate:tests --config parallel -g
1516

1617

1718
3.10.3

Diff for: dev/tests/unit/Magento/FunctionalTestFramework/Util/Sorter/ParallelGroupSorterTest.php

+42
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,48 @@ public function testTestsAndSuitesSplitByMinGroupNumber(): void
378378
}
379379
}
380380

381+
/**
382+
* Test splitting tests and suites when none of the suites has test.
383+
* For example, this can happen when --filter option is used.
384+
*
385+
* @return void
386+
* @throws FastFailException
387+
*/
388+
public function testTestsAndSuitesSplitByGroupNumberSuiteNoTest(): void
389+
{
390+
// mock tests for test object handler.
391+
$this->createMockForTest(0);
392+
393+
// create test to size array
394+
$sampleTestArray = [
395+
'test1' => 1,
396+
'test2' => 125,
397+
'test3' => 35
398+
];
399+
400+
// create mock suite references
401+
$sampleSuiteArray = [
402+
'mockSuite1' => [],
403+
'mockSuite2' => [],
404+
];
405+
406+
// perform sort
407+
$testSorter = new ParallelGroupSorter();
408+
$actualResult = $testSorter->getTestsGroupedByFixedGroupCount($sampleSuiteArray, $sampleTestArray, 3);
409+
// verify the resulting groups
410+
$this->assertCount(3, $actualResult);
411+
412+
$expectedResults = [
413+
1 => ['test2'],
414+
2 => ['test3'],
415+
3 => ['test1']
416+
];
417+
418+
foreach ($actualResult as $groupNum => $group) {
419+
$this->assertEquals($expectedResults[$groupNum], array_keys($group));
420+
}
421+
}
422+
381423
/**
382424
* Test splitting tests and suites with invalid group number.
383425
*

Diff for: src/Magento/FunctionalTestingFramework/Util/Sorter/ParallelGroupSorter.php

+4
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,10 @@ public function getTestsGroupedByFixedGroupCount($suiteConfiguration, $testNameT
128128
*/
129129
private function getSuiteGroupCounts($suiteNameToTestSize, $testNameToSize, $groupTotal)
130130
{
131+
if (empty($suiteNameToTestSize)) {
132+
return [];
133+
}
134+
131135
// Calculate the minimum possible group time
132136
$suiteNameToSize = $this->getSuiteToSize($suiteNameToTestSize);
133137
$minGroupTime = ceil((array_sum($testNameToSize) + array_sum($suiteNameToSize)) / $groupTotal);

0 commit comments

Comments
 (0)