Skip to content

Commit 588649e

Browse files
authored
Merge pull request #225 from magento-commerce/ACQE-3464
ACQE-4122: fixed an issue in test generation with config parallel by …
2 parents db1b01e + 71df78e commit 588649e

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

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
*

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)