Skip to content

Commit aa3aa8e

Browse files
magterskineimeron2433
authored andcommitted
MQE-561: [ALLURE] Add an enum to the "Severity" annotation xml schema.
- Added enum of Magento severity values to mergedtestschema.xsd - Added conditional to AnnotationExtractor.php to check if anotation is "Severity" - Added method transformAllureSeveritytoMagento to AnnotationExtractor.php to transform Magento severity to Allure severity
1 parent 07744f0 commit aa3aa8e

File tree

2 files changed

+50
-2
lines changed

2 files changed

+50
-2
lines changed

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

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,13 @@
1212
class AnnotationExtractor extends BaseObjectExtractor
1313
{
1414
const ANNOTATION_VALUE = 'value';
15+
const MAGENTO_TO_ALLURE_SEVERITY_MAP = [
16+
"BLOCKER" => "BLOCKER",
17+
"CRITICAL" => "MAJOR",
18+
"MAJOR" => "NORMAL",
19+
"AVERAGE" => "MINOR",
20+
"MINOR" => "TRIVIAL"
21+
];
1522

1623
/**
1724
* AnnotationExtractor constructor.
@@ -30,19 +37,44 @@ public function __construct()
3037
*/
3138
public function extractAnnotations($testAnnotations)
3239
{
40+
3341
$annotationObjects = [];
3442
$annotations = $this->stripDescriptorTags($testAnnotations, self::NODE_NAME);
3543

3644
// parse the Test annotations
45+
3746
foreach ($annotations as $annotationKey => $annotationData) {
3847
$annotationValues = [];
48+
// Only transform severity annotation
49+
if ($annotationKey == "Severity") {
50+
$annotationObjects[$annotationKey] = $this->transformAllureSeverityToMagento($annotationData);
51+
continue;
52+
}
53+
3954
foreach ($annotationData as $annotationValue) {
4055
$annotationValues[] = $annotationValue[self::ANNOTATION_VALUE];
4156
}
42-
4357
$annotationObjects[$annotationKey] = $annotationValues;
4458
}
4559

4660
return $annotationObjects;
4761
}
62+
63+
/**
64+
* This method transforms Magento severity values from Severity annotation
65+
* Returns Allure annotation value
66+
*
67+
* @param array $annotationData
68+
* @return array
69+
*/
70+
public function transformAllureSeverityToMagento($annotationData)
71+
{
72+
$annotationValue = strtoupper($annotationData[0]);
73+
//Mapping Magento severity to Allure Severity
74+
//Attempts to resolve annotationValue reference against MAGENTO_TO_ALLURE_SEVERITY_MAP -
75+
// if not found returns without modification
76+
$allureAnnotation[] = self::MAGENTO_TO_ALLURE_SEVERITY_MAP[$annotationValue] ?? $annotationValue;
77+
78+
return $allureAnnotation;
79+
}
4880
}

src/Magento/FunctionalTestingFramework/Test/etc/mergedTestSchema.xsd

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,20 +25,36 @@
2525
<xs:element type="annotationType" name="stories" minOccurs="0" maxOccurs="unbounded"/>
2626
<xs:element type="annotationType" name="title" minOccurs="0" maxOccurs="unbounded"/>
2727
<xs:element type="annotationType" name="description" minOccurs="0" maxOccurs="unbounded"/>
28-
<xs:element type="annotationType" name="severity" minOccurs="0" maxOccurs="unbounded"/>
28+
<xs:element type="severityType" name="severity" minOccurs="0" maxOccurs="unbounded"/>
2929
<xs:element type="annotationType" name="testCaseId" minOccurs="0" maxOccurs="unbounded"/>
3030
<xs:element type="annotationType" name="useCaseId" minOccurs="0" maxOccurs="unbounded"/>
3131
<xs:element type="annotationType" name="group" minOccurs="0" maxOccurs="unbounded"/>
3232
<xs:element type="annotationType" name="return" minOccurs="0" maxOccurs="unbounded"/>
3333
</xs:choice>
3434
</xs:complexType>
35+
<xs:simpleType name="severityEnum" final="restriction">
36+
<xs:restriction base="xs:string">
37+
<xs:enumeration value="MINOR"/>
38+
<xs:enumeration value="AVERAGE"/>
39+
<xs:enumeration value="MAJOR"/>
40+
<xs:enumeration value="BLOCKER"/>
41+
<xs:enumeration value="CRITICAL"/>
42+
</xs:restriction>
43+
</xs:simpleType>
3544
<xs:complexType name="annotationType">
3645
<xs:simpleContent>
3746
<xs:extension base="xs:string">
3847
<xs:attribute type="xs:string" name="value" use="required"/>
3948
</xs:extension>
4049
</xs:simpleContent>
4150
</xs:complexType>
51+
<xs:complexType name="severityType">
52+
<xs:simpleContent>
53+
<xs:extension base="xs:string">
54+
<xs:attribute type="severityEnum" name="value" use="required"/>
55+
</xs:extension>
56+
</xs:simpleContent>
57+
</xs:complexType>
4258
<xs:complexType name="hookType">
4359
<xs:choice minOccurs="0" maxOccurs="unbounded">
4460
<xs:group ref="testTypeTags"/>

0 commit comments

Comments
 (0)