Skip to content

Commit 74c98cf

Browse files
committed
MQE-893: Add flag to robo generate: tests which accepts a specific set of tests to execute
- introduce new robo flag to generate tests command
1 parent 1092d28 commit 74c98cf

File tree

1 file changed

+24
-12
lines changed

1 file changed

+24
-12
lines changed

dev/tests/acceptance/RoboFile.php

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -114,29 +114,43 @@ function buildProject()
114114
* @return void
115115
*/
116116

117-
function generateTests(array $tests, $opts = ['config' => null, 'force' => false, 'nodes' => null, 'lines' => null])
117+
function generateTests(array $tests, $opts = [
118+
'config' => null,
119+
'force' => false,
120+
'nodes' => null,
121+
'lines' => null,
122+
'tests' => null
123+
])
118124
{
119125
$GLOBALS['GENERATE_TESTS'] = true;
120126
require 'tests'. DIRECTORY_SEPARATOR . 'functional' . DIRECTORY_SEPARATOR . '_bootstrap.php';
121-
$testsObjects = [];
127+
$testObjects = [];
128+
$suitesReferences = [];
129+
130+
if ($opts['force'])
131+
{
132+
$GLOBALS['FORCE_PHP_GENERATE'] = true;
133+
}
134+
135+
if ($opts['tests']) {
136+
$testConfigArray = json_decode($opts['tests'],true);
137+
$tests = $testConfigArray['tests'] ?? [];
138+
$suitesReferences = $testConfigArray['suites'] ?? [];
139+
}
140+
122141
if (!empty($tests))
123142
{
124143
foreach ($tests as $test)
125144
{
126-
$testsObjects[] = Magento\FunctionalTestingFramework\Test\Handlers\TestObjectHandler::getInstance()->getObject($test);
145+
$testObjects[] = Magento\FunctionalTestingFramework\Test\Handlers\TestObjectHandler::getInstance()->getObject($test);
127146
}
128147
}
129148

130-
if ($opts['force'])
131-
{
132-
$GLOBALS['FORCE_PHP_GENERATE'] = true;
133-
}
134-
135149
// maintain backwards compatability for devops
136150
$lines = $opts['lines'] ?? $opts ['nodes'];
137151

138-
$testsReferencedInSuites = \Magento\FunctionalTestingFramework\Suite\SuiteGenerator::getInstance()->getTestsReferencedInSuites();
139-
$testManifest = \Magento\FunctionalTestingFramework\Util\TestGenerator::getInstance(null, $testsObjects)->createAllTestFiles($opts['config'], $lines, $testsReferencedInSuites);
152+
$testsReferencedInSuites = \Magento\FunctionalTestingFramework\Suite\SuiteGenerator::getInstance($suitesReferences)->getTestsReferencedInSuites();
153+
$testManifest = \Magento\FunctionalTestingFramework\Util\TestGenerator::getInstance(null, $testObjects)->createAllTestFiles($opts['config'], $lines, $testsReferencedInSuites);
140154
\Magento\FunctionalTestingFramework\Suite\SuiteGenerator::getInstance()->generateAllSuites($testManifest);
141155

142156
$this->say("Generate Tests Command Run");
@@ -281,6 +295,4 @@ function preInstall()
281295
{
282296
$this->_exec('php pre-install.php');
283297
}
284-
285-
286298
}

0 commit comments

Comments
 (0)