Skip to content

Commit a9041d5

Browse files
committed
MQE-1800: Allow generate:tests to continue running even if one test fails generation
1 parent c7eb83b commit a9041d5

File tree

8 files changed

+25
-14
lines changed

8 files changed

+25
-14
lines changed

Diff for: src/Magento/FunctionalTestingFramework/Console/GenerateTestsCommand.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,8 @@ private function createTestConfiguration(
205205
LoggingUtil::getInstance()->getLogger(self::class)->error(
206206
$message. PHP_EOL . $e->getMessage()
207207
);
208-
if (MftfApplicationConfig::getConfig()->getPhase() == MftfApplicationConfig::GENERATION_PHASE) {
208+
if (MftfApplicationConfig::getConfig()->verboseEnabled()
209+
&& MftfApplicationConfig::getConfig()->getPhase() == MftfApplicationConfig::GENERATION_PHASE) {
209210
print($message . PHP_EOL);
210211
}
211212
if (MftfApplicationConfig::getConfig()->getPhase() != MftfApplicationConfig::EXECUTION_PHASE) {

Diff for: src/Magento/FunctionalTestingFramework/DataGenerator/Handlers/PersistedObjectHandler.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,8 @@ public function retrieveEntityField($stepKey, $field, $scope)
194194
$warnMsg .= "Please fix the invalid reference. This will result in fatal error in next major release.";
195195
//TODO: change this to throw an exception in next major release
196196
LoggingUtil::getInstance()->getLogger(PersistedObjectHandler::class)->warn($warnMsg);
197-
if (MftfApplicationConfig::getConfig()->getPhase() !== MftfApplicationConfig::UNIT_TEST_PHASE) {
197+
if (MftfApplicationConfig::getConfig()->verboseEnabled()
198+
&& MftfApplicationConfig::getConfig()->getPhase() !== MftfApplicationConfig::UNIT_TEST_PHASE) {
198199
print("\n$warnMsg\n");
199200
}
200201
}

Diff for: src/Magento/FunctionalTestingFramework/DataGenerator/Util/DataExtensionUtil.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ public function extendEntity($entityObject)
5252
PHP_EOL
5353
);
5454
}
55-
if (MftfApplicationConfig::getConfig()->verboseEnabled() &&
56-
MftfApplicationConfig::getConfig()->getPhase() !== MftfApplicationConfig::UNIT_TEST_PHASE) {
55+
if (MftfApplicationConfig::getConfig()->verboseEnabled()
56+
&& MftfApplicationConfig::getConfig()->getPhase() !== MftfApplicationConfig::UNIT_TEST_PHASE) {
5757
print("Extending Data: " . $parentEntity->getName() . " => " . $entityObject->getName() . PHP_EOL);
5858
}
5959

Diff for: src/Magento/FunctionalTestingFramework/Suite/Util/SuiteObjectExtractor.php

+4-2
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,8 @@ public function parseSuiteDataIntoObjects($parsedSuiteData)
126126

127127
if (!empty($includeMessage)) {
128128
LoggingUtil::getInstance()->getLogger(self::class)->error($includeMessage);
129-
if (MftfApplicationConfig::getConfig()->getPhase() == MftfApplicationConfig::GENERATION_PHASE) {
129+
if (MftfApplicationConfig::getConfig()->verboseEnabled()
130+
&& MftfApplicationConfig::getConfig()->getPhase() == MftfApplicationConfig::GENERATION_PHASE) {
130131
print($includeMessage);
131132
}
132133
if (MftfApplicationConfig::getConfig()->getPhase() != MftfApplicationConfig::EXECUTION_PHASE) {
@@ -144,7 +145,8 @@ public function parseSuiteDataIntoObjects($parsedSuiteData)
144145
LoggingUtil::getInstance()->getLogger(self::class)->error(
145146
"Unable to parse suite " . $parsedSuite[self::NAME] . "\n" . $e->getMessage()
146147
);
147-
if (MftfApplicationConfig::getConfig()->getPhase() == MftfApplicationConfig::GENERATION_PHASE) {
148+
if (MftfApplicationConfig::getConfig()->verboseEnabled()
149+
&& MftfApplicationConfig::getConfig()->getPhase() == MftfApplicationConfig::GENERATION_PHASE) {
148150
print("ERROR: Unable to parse suite " . $parsedSuite[self::NAME] . "\n");
149151
}
150152
if (MftfApplicationConfig::getConfig()->getPhase() != MftfApplicationConfig::EXECUTION_PHASE) {

Diff for: src/Magento/FunctionalTestingFramework/Test/Handlers/TestObjectHandler.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ public function getAllObjects()
125125
}
126126

127127
if ($errCount > 0
128+
&& MftfApplicationConfig::getConfig()->verboseEnabled()
128129
&& MftfApplicationConfig::getConfig()->getPhase() == MftfApplicationConfig::GENERATION_PHASE) {
129130
print(
130131
"ERROR: "
@@ -174,6 +175,7 @@ public function getTestsByGroup($groupName)
174175
}
175176

176177
if ($errCount > 0
178+
&& MftfApplicationConfig::getConfig()->verboseEnabled()
177179
&& MftfApplicationConfig::getConfig()->getPhase() == MftfApplicationConfig::GENERATION_PHASE) {
178180
print(
179181
"ERROR: "
@@ -248,7 +250,8 @@ private function initTestData($validateAnnotations = true)
248250
LoggingUtil::getInstance()->getLogger(self::class)->error(
249251
"Unable to parse test " . $testName . "\n" . $exception->getMessage()
250252
);
251-
if (MftfApplicationConfig::getConfig()->getPhase() == MftfApplicationConfig::GENERATION_PHASE) {
253+
if (MftfApplicationConfig::getConfig()->verboseEnabled()
254+
&& MftfApplicationConfig::getConfig()->getPhase() == MftfApplicationConfig::GENERATION_PHASE) {
252255
print("ERROR: Unable to parse test " . $testName . "\n");
253256
}
254257
if (MftfApplicationConfig::getConfig()->getPhase() != MftfApplicationConfig::EXECUTION_PHASE) {

Diff for: src/Magento/FunctionalTestingFramework/Test/Util/AnnotationExtractor.php

+4-2
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,8 @@ public function validateStoryTitleUniqueness()
193193
foreach ($dupes as $storyTitle => $tests) {
194194
$message = "Story and Title annotation pairs is not unique in Tests {$tests}\n";
195195
LoggingUtil::getInstance()->getLogger(self::class)->error($message);
196-
if (MftfApplicationConfig::getConfig()->getPhase() == MftfApplicationConfig::GENERATION_PHASE) {
196+
if (MftfApplicationConfig::getConfig()->verboseEnabled()
197+
&& MftfApplicationConfig::getConfig()->getPhase() == MftfApplicationConfig::GENERATION_PHASE) {
197198
print('ERROR: ' . $message);
198199
}
199200
$testArray = explode(',', $tests);
@@ -230,7 +231,8 @@ public function validateTestCaseIdTitleUniqueness()
230231
foreach ($dupes as $newTitle => $tests) {
231232
$message = "TestCaseId and Title pairs is not unique in Tests {$tests}\n";
232233
LoggingUtil::getInstance()->getLogger(self::class)->error($message);
233-
if (MftfApplicationConfig::getConfig()->getPhase() == MftfApplicationConfig::GENERATION_PHASE) {
234+
if (MftfApplicationConfig::getConfig()->verboseEnabled()
235+
&& MftfApplicationConfig::getConfig()->getPhase() == MftfApplicationConfig::GENERATION_PHASE) {
234236
print('ERROR: ' . $message);
235237
}
236238
$testArray = explode(',', $tests);

Diff for: src/Magento/FunctionalTestingFramework/Util/GenerationErrorHandler.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -121,22 +121,22 @@ public function printErrorSummary()
121121
$totalNotGenErrors = $totalErrors - $totalAnnotationErrors;
122122
if ($totalNotGenErrors > 0) {
123123
print(
124-
PHP_EOL
125-
. 'ERROR: '
124+
'ERROR: '
126125
. strval($totalNotGenErrors)
127126
. ' '
128127
. ucfirst($type)
129128
. "(s) failed to generate. See mftf.log for details."
129+
. PHP_EOL
130130
);
131131
}
132132
if ($totalAnnotationErrors > 0) {
133133
print(
134-
PHP_EOL
135-
. 'ERROR: '
134+
'ERROR: '
136135
. strval($totalAnnotationErrors)
137136
. ' '
138137
. ucfirst($type)
139138
. "(s) generated with annotation errors. See mftf.log for details."
139+
. PHP_EOL
140140
);
141141
}
142142
}

Diff for: src/Magento/FunctionalTestingFramework/Util/TestGenerator.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,9 @@ private function assembleAllTestPhp($testManifest, array $testsToIgnore)
358358
if (MftfApplicationConfig::getConfig()->getPhase() == MftfApplicationConfig::GENERATION_PHASE) {
359359
$errMessage = "{$test->getName()} will not be generated. "
360360
. "Parent test {$test->getParentName()} not defined in xml.";
361-
print("ERROR: {$errMessage}");
361+
if (MftfApplicationConfig::getConfig()->verboseEnabled()) {
362+
print("ERROR: {$errMessage}");
363+
}
362364
LoggingUtil::getInstance()->getLogger(self::class)->error($errMessage);
363365
GenerationErrorHandler::getInstance()->addError(
364366
'test',

0 commit comments

Comments
 (0)