Skip to content

Mqe 1754 #451

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
Sep 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion docs/commands/mftf.md
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ Complex configuration to generate a few non-suite tests, a single test in a suit
The command that encodes this complex configuration:

```bash
vendor/bin/mftf generate:tests --tests "{\r\n\"tests\":[\r\n\"general_test1\",\r\n\"general_test2\",\r\n\"general_test3\"\r\n],\r\n\"suites\":{\r\n\"sample\":[\r\n\"suite_test1\"\r\n],\r\n\"sample2\":null\r\n}\r\n}"
vendor/bin/mftf generate:tests --tests '{"tests":["general_test1","general_test2","general_test3"],"suites":{"sample":["suite_test1"],"sample2":null}}'
```

Note that the strings must be escaped and surrounded in quotes.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,13 @@ private function __construct(
* @return void
* @throws TestFrameworkException
*/
public static function create($forceGenerate, $phase, $verboseEnabled, $debugLevel, $allowSkipped)
{
public static function create(
$forceGenerate = false,
$phase = self::EXECUTION_PHASE,
$verboseEnabled = null,
$debugLevel = self::LEVEL_NONE,
$allowSkipped = false
) {
if (self::$MFTF_APPLICATION_CONTEXT == null) {
self::$MFTF_APPLICATION_CONTEXT =
new MftfApplicationConfig($forceGenerate, $phase, $verboseEnabled, $debugLevel, $allowSkipped);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ protected function execute(InputInterface $input, OutputInterface $output)
$force,
MftfApplicationConfig::GENERATION_PHASE,
false,
MftfApplicationConfig::LEVEL_NONE
MftfApplicationConfig::LEVEL_NONE,
true
);

$allActionGroups = ActionGroupObjectHandler::getInstance()->getAllObjects();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,20 @@ protected function configure()
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$force = $input->getOption('force');
$debug = $input->getOption('debug') ?? MftfApplicationConfig::LEVEL_DEVELOPER; // for backward compatibility
$remove = $input->getOption('remove');
$verbose = $output->isVerbose();
$allowSkipped = $input->getOption('allowSkipped');

// Set application configuration so we can references the user options in our framework
MftfApplicationConfig::create(
$force,
MftfApplicationConfig::GENERATION_PHASE,
$verbose,
$debug,
$allowSkipped
);

// Remove previous GENERATED_DIR if --remove option is used
if ($remove) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,15 @@ protected function execute(InputInterface $input, OutputInterface $output)
$verbose = $output->isVerbose();
$allowSkipped = $input->getOption('allowSkipped');

// Set application configuration so we can references the user options in our framework
MftfApplicationConfig::create(
$force,
MftfApplicationConfig::GENERATION_PHASE,
$verbose,
$debug,
$allowSkipped
);

if (!empty($tests)) {
$json = $this->getTestAndSuiteConfiguration($tests);
}
Expand All @@ -93,7 +102,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
($debug !== MftfApplicationConfig::LEVEL_NONE));
}

$testConfiguration = $this->createTestConfiguration($json, $tests, $force, $debug, $verbose, $allowSkipped);
$testConfiguration = $this->createTestConfiguration($json, $tests);

// create our manifest file here
$testManifest = TestManifestFactory::makeManifest($config, $testConfiguration['suites']);
Expand All @@ -114,33 +123,16 @@ protected function execute(InputInterface $input, OutputInterface $output)
/**
* Function which builds up a configuration including test and suites for consumption of Magento generation methods.
*
* @param string $json
* @param array $tests
* @param boolean $force
* @param string $debug
* @param boolean $verbose
* @param boolean $allowSkipped
* @param string $json
* @param array $tests
* @return array
* @throws \Magento\FunctionalTestingFramework\Exceptions\TestReferenceException
* @throws \Magento\FunctionalTestingFramework\Exceptions\XmlException
*/
private function createTestConfiguration(
$json,
array $tests,
bool $force,
string $debug,
bool $verbose,
bool $allowSkipped
array $tests
) {
// set our application configuration so we can references the user options in our framework
MftfApplicationConfig::create(
$force,
MftfApplicationConfig::GENERATION_PHASE,
$verbose,
$debug,
$allowSkipped
);

$testConfiguration = [];
$testConfiguration['tests'] = $tests;
$testConfiguration['suites'] = [];
Expand Down
20 changes: 18 additions & 2 deletions src/Magento/FunctionalTestingFramework/Console/RunTestCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,12 @@ protected function configure()
'name',
InputArgument::REQUIRED | InputArgument::IS_ARRAY,
"name of tests to generate and execute"
)->addOption('skip-generate', 'k', InputOption::VALUE_NONE, "skip generation and execute existing test");
)->addOption(
'skip-generate',
'k',
InputOption::VALUE_NONE,
"skip generation and execute existing test"
);

parent::configure();
}
Expand All @@ -55,6 +60,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$remove = $input->getOption('remove');
$debug = $input->getOption('debug') ?? MftfApplicationConfig::LEVEL_DEVELOPER; // for backward compatibility
$allowSkipped = $input->getOption('allowSkipped');
$verbose = $output->isVerbose();

if ($skipGeneration and $remove) {
// "skip-generate" and "remove" options cannot be used at the same time
Expand All @@ -63,6 +69,15 @@ protected function execute(InputInterface $input, OutputInterface $output): int
);
}

// Set application configuration so we can references the user options in our framework
MftfApplicationConfig::create(
$force,
MftfApplicationConfig::EXECUTION_PHASE,
$verbose,
$debug,
$allowSkipped
);

$testConfiguration = $this->getTestAndSuiteConfiguration($tests);

if (!$skipGeneration) {
Expand All @@ -72,7 +87,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int
'--force' => $force,
'--remove' => $remove,
'--debug' => $debug,
'--allowSkipped' => $allowSkipped
'--allowSkipped' => $allowSkipped,
'-v' => $verbose
];
$command->run(new ArrayInput($args), $output);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,13 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$force = $input->getOption('force');
$debug = $input->getOption('debug') ?? MftfApplicationConfig::LEVEL_DEVELOPER; // for backward compatibility
$allowSkipped = $input->getOption('allowSkipped');
$verbose = $output->isVerbose();

// Create Mftf Configuration
MftfApplicationConfig::create(
$force,
MftfApplicationConfig::GENERATION_PHASE,
false,
MftfApplicationConfig::EXECUTION_PHASE,
$verbose,
$debug,
$allowSkipped
);
Expand All @@ -91,9 +92,11 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$command = $this->getApplication()->find('generate:tests');
$args = [
'--tests' => $testConfiguration,
'--force' => $force,
'--remove' => true,
'--debug' => $debug,
'--allowSkipped' => $allowSkipped
'--allowSkipped' => $allowSkipped,
'-v' => $verbose
];
$command->run(new ArrayInput($args), $output);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$remove = $input->getOption('remove');
$debug = $input->getOption('debug') ?? MftfApplicationConfig::LEVEL_DEVELOPER; // for backward compatibility
$allowSkipped = $input->getOption('allowSkipped');
$verbose = $output->isVerbose();

if ($skipGeneration and $remove) {
// "skip-generate" and "remove" options cannot be used at the same time
Expand All @@ -72,8 +73,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int
// Create Mftf Configuration
MftfApplicationConfig::create(
$force,
MftfApplicationConfig::GENERATION_PHASE,
false,
MftfApplicationConfig::EXECUTION_PHASE,
$verbose,
$debug,
$allowSkipped
);
Expand All @@ -86,7 +87,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int
'--force' => $force,
'--remove' => $remove,
'--debug' => $debug,
'--allowSkipped' => $allowSkipped
'--allowSkipped' => $allowSkipped,
'-v' => $verbose
];

$command->run(new ArrayInput($args), $output);
Expand Down