Skip to content

Commit ee12a62

Browse files
authored
Merge pull request #427 from magento/MQE-1331
MQE-1331: MFTF Run:Test Will Run All Tests That Are Already Generated
2 parents 8f54cbb + 9006361 commit ee12a62

File tree

1 file changed

+25
-12
lines changed

1 file changed

+25
-12
lines changed

src/Magento/FunctionalTestingFramework/Console/RunTestCommand.php

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
namespace Magento\FunctionalTestingFramework\Console;
99

1010
use Magento\FunctionalTestingFramework\Config\MftfApplicationConfig;
11+
use Magento\FunctionalTestingFramework\Util\TestGenerator;
1112
use Symfony\Component\Console\Input\ArrayInput;
1213
use Symfony\Component\Console\Input\InputArgument;
1314
use Symfony\Component\Console\Input\InputInterface;
@@ -77,18 +78,30 @@ protected function execute(InputInterface $input, OutputInterface $output): int
7778
$command->run(new ArrayInput($args), $output);
7879
}
7980

80-
// we only generate relevant tests here so we can execute "all tests"
81-
$codeceptionCommand = realpath(PROJECT_ROOT . '/vendor/bin/codecept') . " run functional --verbose --steps";
82-
83-
$process = new Process($codeceptionCommand);
84-
$process->setWorkingDirectory(TESTS_BP);
85-
$process->setIdleTimeout(600);
86-
$process->setTimeout(0);
87-
88-
return $process->run(
89-
function ($type, $buffer) use ($output) {
90-
$output->write($buffer);
81+
$returnCode = 0;
82+
$codeceptionCommand = realpath(PROJECT_ROOT . '/vendor/bin/codecept') . ' run functional ';
83+
$testsDirectory = TESTS_MODULE_PATH . DIRECTORY_SEPARATOR . TestGenerator::GENERATED_DIR . DIRECTORY_SEPARATOR;
84+
//execute only tests specified as arguments in run command
85+
foreach ($tests as $test) {
86+
$testGroup = TestGenerator::DEFAULT_DIR . DIRECTORY_SEPARATOR;
87+
$testName = $test . 'Cest.php';
88+
if (!realpath($testsDirectory . $testGroup . $testName)) {
89+
throw new TestFrameworkException(
90+
$testName . " is not available under " . $testsDirectory . $testGroup
91+
);
9192
}
92-
);
93+
$fullCommand = $codeceptionCommand . $testsDirectory . $testGroup . $testName . ' --verbose --steps';
94+
$process = new Process($fullCommand);
95+
$process->setWorkingDirectory(TESTS_BP);
96+
$process->setIdleTimeout(600);
97+
$process->setTimeout(0);
98+
99+
$returnCode = max($returnCode, $process->run(
100+
function ($type, $buffer) use ($output) {
101+
$output->write($buffer);
102+
}
103+
));
104+
}
105+
return $returnCode;
93106
}
94107
}

0 commit comments

Comments
 (0)