Skip to content

Commit 57e515a

Browse files
committed
MQE-2463: Mftf test extends from a skipped parent should be skipped
1 parent d090f55 commit 57e515a

File tree

3 files changed

+63
-4
lines changed

3 files changed

+63
-4
lines changed

dev/tests/unit/Magento/FunctionalTestFramework/Test/Util/ObjectExtensionUtilTest.php

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,41 @@ public function testExtendingExtendedActionGroup()
346346
}
347347
}
348348

349+
/**
350+
* Tests generating a test that extends a skipped parent test
351+
*
352+
* @throws \Exception
353+
*/
354+
public function testExtendedTestSkippedParent()
355+
{
356+
$testDataArrayBuilder = new TestDataArrayBuilder();
357+
$mockParentTest = $testDataArrayBuilder
358+
->withName('baseTest')
359+
->withAnnotations([
360+
'skip' => ['nodeName' => 'skip', 'issueId' => [['nodeName' => 'issueId', 'value' => 'someIssue']]]
361+
])
362+
->build();
363+
364+
$testDataArrayBuilder->reset();
365+
$mockExtendedTest = $testDataArrayBuilder
366+
->withName('extendTest')
367+
->withTestReference("baseTest")
368+
->build();
369+
370+
$mockTestData = array_merge($mockParentTest, $mockExtendedTest);
371+
$this->setMockTestOutput($mockTestData);
372+
373+
// parse and generate test object with mocked data
374+
TestObjectHandler::getInstance()->getObject('extendTest');
375+
376+
// validate log statement
377+
TestLoggingUtil::getInstance()->validateMockLogStatement(
378+
'debug',
379+
"extendTest is skipped due to ParentTestIsSkipped",
380+
[]
381+
);
382+
}
383+
349384
/**
350385
* Function used to set mock for parser return and force init method to run between tests.
351386
*

dev/tests/unit/Util/TestDataArrayBuilder.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,28 @@ public function withTestReference($reference = null)
232232
return $this;
233233
}
234234

235+
/**
236+
* Reset data array builder
237+
*
238+
* @return void
239+
*/
240+
public function reset()
241+
{
242+
// reset
243+
$this->testName = 'testTest';
244+
$this->filename = null;
245+
$this->testActionBeforeName = 'testActionBefore';
246+
$this->testActionAfterName = 'testActionAfter';
247+
$this->testActionFailedName = 'testActionFailed';
248+
$this->testActionType = 'testAction';
249+
$this->annotations = [];
250+
$this->beforeHook = [];
251+
$this->afterHook = [];
252+
$this->failedHook = [];
253+
$this->testReference = null;
254+
$this->testActions = [];
255+
}
256+
235257
/**
236258
* Output the resulting test data array based on parameters set in the object
237259
*

src/Magento/FunctionalTestingFramework/Test/Util/ObjectExtensionUtil.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,13 @@ public function extendTest($testObject)
4242
try {
4343
$parentTest = TestObjectHandler::getInstance()->getObject($testObject->getParentName());
4444
} catch (TestReferenceException $error) {
45+
$skippedTest = $this->skipTest($testObject, 'ParentTestDoesNotExist');
4546
if (MftfApplicationConfig::getConfig()->verboseEnabled()) {
4647
LoggingUtil::getInstance()->getLogger(ObjectExtensionUtil::class)->debug(
4748
"parent test not defined. test will be skipped",
4849
["parent" => $testObject->getParentName(), "test" => $testObject->getName()]
4950
);
5051
}
51-
$skippedTest = $this->skipTest($testObject, 'ParentTestDoesNotExist');
5252
return $skippedTest;
5353
}
5454

@@ -236,9 +236,11 @@ public function skipTest($testObject, $skipReason = null)
236236
$testObject->getParentName()
237237
);
238238

239-
LoggingUtil::getInstance()->getLogger(ObjectExtensionUtil::class)->info(
240-
"\nMQE-2463 LOGGING: {$testObject->getName()} is skipped due to {$skipReason}\n"
241-
);
239+
if (MftfApplicationConfig::getConfig()->verboseEnabled()) {
240+
LoggingUtil::getInstance()->getLogger(ObjectExtensionUtil::class)->debug(
241+
"{$testObject->getName()} is skipped due to {$skipReason}"
242+
);
243+
}
242244

243245
return $skippedTest;
244246
}

0 commit comments

Comments
 (0)