Skip to content

MQE-1581: Remove NONE debug level for next MFTF major release #612

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 3 commits into from
Mar 11, 2020
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 dev/tests/_bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
true,
\Magento\FunctionalTestingFramework\Config\MftfApplicationConfig::UNIT_TEST_PHASE,
true,
\Magento\FunctionalTestingFramework\Config\MftfApplicationConfig::LEVEL_NONE,
\Magento\FunctionalTestingFramework\Config\MftfApplicationConfig::LEVEL_DEFAULT,
false
);

Expand Down
8 changes: 4 additions & 4 deletions docs/commands/mftf.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ vendor/bin/mftf generate:tests [option] [<test name>] [<test name>] [--remove]
| `-i,--time` | Set time in minutes to determine the group size when `--config=parallel` is used. The __default value__ is `10`. Example: `generate:tests --config=parallel --time=15`|
| `--tests` | Defines the test configuration as a JSON string.|
| `--allow-skipped` | Allows MFTF to generate and run tests marked with `<skip>.`|
| `--debug or --debug=[<none>]`| Performs schema validations on XML files. <br/> DEFAULT: `generate:tests` implicitly performs schema validation on merged files. It does not indicate the file name where the error is encountered. <br/> DEVELOPER: `--debug` performs per-file validation and returns additional debug information (such as the filename where an error occurred) when test generation fails because of an invalid XML schema. This option takes extra processing time. Use it after test generation has failed once.<br/>NONE: `--debug=none` skips debugging during test generation. Added for backward compatibility, it will be removed in the next MAJOR release.<br/>|
| `--debug` | Performs schema validations on XML files. <br/> DEFAULT: `generate:tests` implicitly performs schema validation on merged files. It does not indicate the file name where the error is encountered. <br/> DEVELOPER: `--debug` performs per-file validation and returns additional debug information (such as the filename where an error occurred) when test generation fails because of an invalid XML schema. This option takes extra processing time. Use it after test generation has failed once.<br/>|
| `-r,--remove`| Removes the existing generated suites and tests cleaning up the `_generated` directory before the actual run. For example, `generate:tests SampleTest --remove` cleans up the entire `_generated` directory and generates `SampleTest` only.|

#### Examples of the JSON configuration
Expand Down Expand Up @@ -337,7 +337,7 @@ vendor/bin/mftf run:group [--skip-generate|--remove] [--] <group1> [<group2>]
| --------------------- | --------------------------------------------------------------------------------------------------------- |
| `-k, --skip-generate` | Skips generating from the source XML. Instead, the command executes previously-generated groups of tests. |
| `-r, --remove` | Removes previously generated suites and tests before the actual generation and run. |
| `--debug or --debug=[<none>]`| Performs schema validations on XML files. `run:group` implicitly performs schema validation on merged files. It does not indicate the file name where the error is encountered. `--debug` performs per-file validation and returns additional debug information (such as the filename where an error occurred). `--debug=none` skips debugging during test run. Added for backward compatibility, it will be removed in the next MAJOR release.|
| `--debug` | Performs schema validations on XML files. `run:group` implicitly performs schema validation on merged files. It does not indicate the file name where the error is encountered. `--debug` performs per-file validation and returns additional debug information (such as the filename where an error occurred).|

#### Examples

Expand Down Expand Up @@ -369,7 +369,7 @@ vendor/bin/mftf run:test [--skip-generate|--remove] [--] <name1> [<name2>]
|-----------------------|-----------------------------------------------------------------------------------------------------------|
| `-k, --skip-generate` | Skips generating from the source XML. Instead, the command executes previously-generated groups of tests. |
| `-r, --remove` | Remove previously generated suites and tests. |
| `--debug or --debug=[<none>]`| Performs schema validations on XML files. `run:test` implicitly performs schema validation on merged files. It does not indicate the file name where the error is encountered. `--debug` performs per-file validation and returns additional debug information (such as the filename where an error occurred). `--debug=none` skips debugging during test run. Added for backward compatibility, it will be removed in the next MAJOR release.
| `--debug` | Performs schema validations on XML files. `run:test` implicitly performs schema validation on merged files. It does not indicate the file name where the error is encountered. `--debug` performs per-file validation and returns additional debug information (such as the filename where an error occurred).|

#### Examples

Expand Down Expand Up @@ -419,7 +419,7 @@ vendor/bin/mftf run:failed

| Option | Description |
|-----------------------|-----------------------------------------------------------------------------------------------------------|
| `--debug or --debug=[<none>]`| Performs schema validations on XML files. `run:failed` implicitly performs schema validation on merged files. It does not indicate the file name where the error is encountered. `--debug` performs per-file validation and returns additional debug information (such as the filename where an error occurred). Use it after test run has failed once. `--debug=none` skips debugging during test run. Added for backward compatibility, it will be removed in the next MAJOR release.|
| `--debug` | Performs schema validations on XML files. `run:failed` implicitly performs schema validation on merged files. It does not indicate the file name where the error is encountered. `--debug` performs per-file validation and returns additional debug information (such as the filename where an error occurred). Use it after test run has failed once.|

#### Examples

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ class MftfApplicationConfig
*/
const LEVEL_DEFAULT = "default";
const LEVEL_DEVELOPER = "developer";
const LEVEL_NONE = "none";
const MFTF_DEBUG_LEVEL = [self::LEVEL_DEFAULT, self::LEVEL_DEVELOPER, self::LEVEL_NONE];
const MFTF_DEBUG_LEVEL = [self::LEVEL_DEFAULT, self::LEVEL_DEVELOPER];

/**
* Contains object with test filters.
Expand Down Expand Up @@ -89,7 +88,7 @@ private function __construct(
$forceGenerate = false,
$phase = self::EXECUTION_PHASE,
$verboseEnabled = null,
$debugLevel = self::LEVEL_NONE,
$debugLevel = self::LEVEL_DEFAULT,
$allowSkipped = false,
$filters = []
) {
Expand All @@ -101,14 +100,17 @@ private function __construct(

$this->phase = $phase;
$this->verboseEnabled = $verboseEnabled;
switch ($debugLevel) {
if (isset($debugLevel) && !in_array(strtolower($debugLevel), self::MFTF_DEBUG_LEVEL)) {
throw new TestFrameworkException("{$debugLevel} is not a debug level. Use 'DEFAULT' or 'DEVELOPER'");
}
switch (strtolower($debugLevel)) {
case self::LEVEL_DEVELOPER:
case self::LEVEL_DEFAULT:
case self::LEVEL_NONE:
$this->debugLevel = $debugLevel;
break;
default:
case null:
$this->debugLevel = self::LEVEL_DEVELOPER;
break;
}
$this->allowSkipped = $allowSkipped;
$this->filterList = new FilterList($filters);
Expand All @@ -131,7 +133,7 @@ public static function create(
$forceGenerate = false,
$phase = self::EXECUTION_PHASE,
$verboseEnabled = null,
$debugLevel = self::LEVEL_NONE,
$debugLevel = self::LEVEL_DEFAULT,
$allowSkipped = false,
$filters = []
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ protected function readFiles($fileList)
{
/** @var \Magento\FunctionalTestingFramework\Config\Dom $configMerger */
$configMerger = null;
$debugLevel = MftfApplicationConfig::getConfig()->getDebugLevel();
foreach ($fileList as $key => $content) {
//check if file is empty and continue to next if it is
if (!$this->verifyFileEmpty($content, $fileList->getFilename())) {
Expand All @@ -157,7 +158,7 @@ protected function readFiles($fileList)
} else {
$configMerger->merge($content);
}
if (MftfApplicationConfig::getConfig()->getDebugLevel() === MftfApplicationConfig::LEVEL_DEVELOPER) {
if (strcasecmp($debugLevel, MftfApplicationConfig::LEVEL_DEVELOPER) == 0) {
$this->validateSchema($configMerger, $fileList->getFilename());
}
} catch (\Magento\FunctionalTestingFramework\Config\Dom\ValidationException $e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function readFiles($fileList)
$configMerger->merge($content, $fileList->getFilename(), $exceptionCollector);
}
// run per file validation with generate:tests -d
if ($debugLevel === MftfApplicationConfig::LEVEL_DEVELOPER) {
if (strcasecmp($debugLevel, MftfApplicationConfig::LEVEL_DEVELOPER) == 0) {
$this->validateSchema($configMerger, $fileList->getFilename());
}
} catch (\Magento\FunctionalTestingFramework\Config\Dom\ValidationException $e) {
Expand All @@ -52,7 +52,7 @@ public function readFiles($fileList)
$exceptionCollector->throwException();

//run validation on merged file with generate:tests
if ($debugLevel === MftfApplicationConfig::LEVEL_DEFAULT) {
if (strcasecmp($debugLevel, MftfApplicationConfig::LEVEL_DEFAULT) == 0) {
$this->validateSchema($configMerger);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,7 @@ protected function configure()
'debug',
'd',
InputOption::VALUE_OPTIONAL,
'Run extra validation when generating and running tests. Use option \'none\' to turn off debugging --
added for backward compatibility, will be removed in the next MAJOR release',
'Run extra validation when generating and running tests.',
MftfApplicationConfig::LEVEL_DEFAULT
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$force,
MftfApplicationConfig::GENERATION_PHASE,
false,
MftfApplicationConfig::LEVEL_NONE,
MftfApplicationConfig::LEVEL_DEFAULT,
true
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,7 @@ protected function execute(InputInterface $input, OutputInterface $output)

// Remove previous GENERATED_DIR if --remove option is used
if ($remove) {
$this->removeGeneratedDirectory($output, $verbose ||
($debug !== MftfApplicationConfig::LEVEL_NONE));
$this->removeGeneratedDirectory($output, $verbose);
}

try {
Expand Down