Skip to content

MQE-1331: MFTF Run:Test Will Run All Tests That Are Already Generated #427

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Aug 26, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 26 additions & 11 deletions src/Magento/FunctionalTestingFramework/Console/RunTestCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
namespace Magento\FunctionalTestingFramework\Console;

use Magento\FunctionalTestingFramework\Config\MftfApplicationConfig;
use Magento\FunctionalTestingFramework\Util\TestGenerator;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
Expand Down Expand Up @@ -88,18 +89,32 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$command->run(new ArrayInput($args), $output);
}

// we only generate relevant tests here so we can execute "all tests"
$codeceptionCommand = realpath(PROJECT_ROOT . '/vendor/bin/codecept') . " run functional --verbose --steps";
$returnCode = 0;
//execute only tests specified as arguments in run command
foreach ($tests as $test) {
$codeceptionCommand = realpath(PROJECT_ROOT . '/vendor/bin/codecept') . ' run functional ';
$test = TESTS_MODULE_PATH .
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about restructuring this a little bit:

$returnCode = 0;
        $codeceptionCommand = realpath(PROJECT_ROOT . '/vendor/bin/codecept') . ' run functional ';
        $testsDirectory = TESTS_MODULE_PATH . DIRECTORY_SEPARATOR . TestGenerator::GENERATED_DIR . DIRECTORY_SEPARATOR;
        //execute only tests specified as arguments in run command
        foreach ($tests as $test) {
            $testGroup = TestGenerator::DEFAULT_DIR . DIRECTORY_SEPARATOR;
            $testName = $test . 'Cest.php';
            $fullCommand = $codeceptionCommand . $testsDirectory . $testGroup . $testName . '--verbose --steps';

This sets up for easier refactor when we implement running a test in the suite context, since whoever touches it only needs to redefine $testGroup

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Restructured it this way. I like the part where we are moving static portions of the command outside of foreach.

DIRECTORY_SEPARATOR .
TestGenerator::GENERATED_DIR .
DIRECTORY_SEPARATOR .
TestGenerator::DEFAULT_DIR .
DIRECTORY_SEPARATOR .
$test .
'Cest.php';
$codeceptionCommand .= $test;
$codeceptionCommand .= ' --verbose --steps';

$process = new Process($codeceptionCommand);
$process->setWorkingDirectory(TESTS_BP);
$process->setIdleTimeout(600);
$process->setTimeout(0);
$process = new Process($codeceptionCommand);
$process->setWorkingDirectory(TESTS_BP);
$process->setIdleTimeout(600);
$process->setTimeout(0);

return $process->run(
function ($type, $buffer) use ($output) {
$output->write($buffer);
}
);
$returnCode = max($returnCode, $process->run(
function ($type, $buffer) use ($output) {
$output->write($buffer);
}
));
}
return $returnCode;
}
}