Skip to content

Commit 27ca94d

Browse files
committed
MFTF deprecation notice attributes
- added 1 more verification test - reduce cli output of deprecated entities
1 parent 9775b5e commit 27ca94d

File tree

8 files changed

+80
-12
lines changed

8 files changed

+80
-12
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
namespace Magento\AcceptanceTest\_default\Backend;
3+
4+
use Magento\FunctionalTestingFramework\AcceptanceTester;
5+
use \Codeception\Util\Locator;
6+
use Yandex\Allure\Adapter\Annotation\Features;
7+
use Yandex\Allure\Adapter\Annotation\Stories;
8+
use Yandex\Allure\Adapter\Annotation\Title;
9+
use Yandex\Allure\Adapter\Annotation\Description;
10+
use Yandex\Allure\Adapter\Annotation\Parameter;
11+
use Yandex\Allure\Adapter\Annotation\Severity;
12+
use Yandex\Allure\Adapter\Model\SeverityLevel;
13+
use Yandex\Allure\Adapter\Annotation\TestCaseId;
14+
15+
/**
16+
* @Description("<h3 class='y-label y-label_status_broken'>Deprecated Notice(s):</h3><ul><li>DEPRECATED ACTION GROUP in Test: DeprecatedActionGroup Deprecated action group</li><li>DEPRECATED SECTION in Test: {{DeprecatedSection.deprecatedElement}} Deprecated section</li><li>DEPRECATED ELEMENT in Test: {{DeprecatedSection.deprecatedElement}} Deprecated element</li><li>DEPRECATED DATA ENTITY in Test: {{DeprecatedData.field}} Data entity deprecated</li><li>DEPRECATED PAGE in Test: {{DeprecatedPage.url}} Deprecated page</li></ul><h3>Test files</h3>verification/TestModule/Test/DeprecatedEntitiesTest.xml<br>")
17+
*/
18+
class DeprecatedEntitiesTestCest
19+
{
20+
/**
21+
* @Features({"TestModule"})
22+
* @Parameter(name = "AcceptanceTester", value="$I")
23+
* @param AcceptanceTester $I
24+
* @return void
25+
* @throws \Exception
26+
*/
27+
public function DeprecatedEntitiesTest(AcceptanceTester $I)
28+
{
29+
$I->comment("Entering Action Group [deprecatedActionGroup] DeprecatedActionGroup");
30+
$I->see("deprecated", "#element"); // stepKey: deprecatedSeeDeprecatedActionGroup
31+
$I->comment("Exiting Action Group [deprecatedActionGroup] DeprecatedActionGroup");
32+
$I->amOnPage("/test.html"); // stepKey: amOnPage
33+
}
34+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="../../../../../src/Magento/FunctionalTestingFramework/Test/etc/testSchema.xsd">
11+
<test name="DeprecatedEntitiesTest">
12+
<actionGroup ref="DeprecatedActionGroup" stepKey="deprecatedActionGroup" />
13+
<amOnPage url="{{DeprecatedPage.url}}" stepKey="amOnPage" />
14+
</test>
15+
</tests>

dev/tests/verification/Tests/DeprecatedTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,15 @@ public function testDeprecatedTestEntitiesGeneration()
1919
{
2020
$this->generateAndCompareTest('DeprecatedTest');
2121
}
22+
23+
/**
24+
* Tests flat generation of a test which uses deprecated entities.
25+
*
26+
* @throws \Exception
27+
* @throws \Magento\FunctionalTestingFramework\Exceptions\TestReferenceException
28+
*/
29+
public function testDeprecatedEntitiesOnlyGeneration()
30+
{
31+
$this->generateAndCompareTest('DeprecatedEntitiesTest');
32+
}
2233
}

src/Magento/FunctionalTestingFramework/Config/Reader/Filesystem.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,8 @@ protected function validateSchema($configMerger, $filename = null)
235235
$error = str_replace(PHP_EOL, "", $error);
236236
LoggingUtil::getInstance()->getLogger(Filesystem::class)->criticalFailure(
237237
"Schema validation error ",
238-
($filename ? [ "file"=> $filename, "error" => $error]: ["error" => $error])
238+
($filename ? [ "file"=> $filename, "error" => $error]: ["error" => $error]),
239+
true
239240
);
240241
}
241242
throw new \Exception("Schema validation errors found in xml file(s)" . $filename);

src/Magento/FunctionalTestingFramework/Test/Objects/ActionObject.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,8 @@ public function trimAssertionAttributes()
314314
if ($appConfig->getPhase() == MftfApplicationConfig::GENERATION_PHASE && $appConfig->verboseEnabled()) {
315315
LoggingUtil::getInstance()->getLogger(ActionObject::class)->deprecation(
316316
"use of one line Assertion actions will be deprecated in MFTF 3.0.0, please use nested syntax",
317-
["action" => $this->type, "stepKey" => $this->stepKey]
317+
["action" => $this->type, "stepKey" => $this->stepKey],
318+
true
318319
);
319320
}
320321
return;

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ private function validateMissingAnnotations($annotationObjects, $filename)
6464
$message = "Action Group File {$filename} is missing required annotations.";
6565
LoggingUtil::getInstance()->getLogger(ActionObject::class)->deprecation(
6666
$message,
67-
["actionGroup" => $filename, "missingAnnotations" => implode(", ", $missingAnnotations)]
67+
["actionGroup" => $filename, "missingAnnotations" => implode(", ", $missingAnnotations)],
68+
true
6869
);
6970
}
7071
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,8 @@ private function validateMissingAnnotations($annotationObjects, $filename)
164164
$message = "Test {$filename} is missing required annotations.";
165165
LoggingUtil::getInstance()->getLogger(ActionObject::class)->deprecation(
166166
$message,
167-
["testName" => $filename, "missingAnnotations" => implode(", ", $missingAnnotations)]
167+
["testName" => $filename, "missingAnnotations" => implode(", ", $missingAnnotations)],
168+
true
168169
);
169170
}
170171
}

src/Magento/FunctionalTestingFramework/Util/Logger/MftfLogger.php

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,17 @@ class MftfLogger extends Logger
1515
/**
1616
* Prints a deprecation warning, as well as adds a log at the WARNING level.
1717
*
18-
* @param string $message The log message.
19-
* @param array $context The log context.
18+
* @param string $message The log message.
19+
* @param array $context The log context.
20+
* @param bool $verbose
2021
* @return void
22+
* @throws \Magento\FunctionalTestingFramework\Exceptions\TestFrameworkException
2123
*/
22-
public function deprecation($message, array $context = [])
24+
public function deprecation($message, array $context = [], $verbose = false)
2325
{
2426
$message = "DEPRECATION: " . $message;
2527
// Suppress print during unit testing
26-
if (MftfApplicationConfig::getConfig()->getPhase() !== MftfApplicationConfig::UNIT_TEST_PHASE) {
28+
if (MftfApplicationConfig::getConfig()->getPhase() !== MftfApplicationConfig::UNIT_TEST_PHASE && $verbose) {
2729
print ($message . json_encode($context) . "\n");
2830
}
2931
parent::warning($message, $context);
@@ -32,15 +34,17 @@ public function deprecation($message, array $context = [])
3234
/**
3335
* Prints a critical failure, as well as adds a log at the CRITICAL level.
3436
*
35-
* @param string $message The log message.
36-
* @param array $context The log context.
37+
* @param string $message The log message.
38+
* @param array $context The log context.
39+
* @param bool $verbose
3740
* @return void
41+
* @throws \Magento\FunctionalTestingFramework\Exceptions\TestFrameworkException
3842
*/
39-
public function criticalFailure($message, array $context = [])
43+
public function criticalFailure($message, array $context = [], $verbose = false)
4044
{
4145
$message = "FAILURE: " . $message;
4246
// Suppress print during unit testing
43-
if (MftfApplicationConfig::getConfig()->getPhase() !== MftfApplicationConfig::UNIT_TEST_PHASE) {
47+
if (MftfApplicationConfig::getConfig()->getPhase() !== MftfApplicationConfig::UNIT_TEST_PHASE && $verbose) {
4448
print ($message . implode("\n", $context) . "\n");
4549
}
4650
parent::critical($message, $context);

0 commit comments

Comments
 (0)