Skip to content

Commit dcd1eca

Browse files
committed
MQE-783: Allure reporting Spike
- semi working solution
1 parent cfb142b commit dcd1eca

File tree

1 file changed

+99
-0
lines changed

1 file changed

+99
-0
lines changed
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\FunctionalTestingFramework\Allure\Adapter;
7+
8+
use Yandex\Allure\Adapter\AllureAdapter;
9+
use Yandex\Allure\Adapter\Annotation;
10+
use Yandex\Allure\Adapter\Event\TestSuiteEvent;
11+
use Yandex\Allure\Adapter\Event\TestSuiteStartedEvent;
12+
use Codeception\Event\SuiteEvent;
13+
14+
/**
15+
* Class MagentoAllureAdapter
16+
*
17+
* Extends AllureAdapter to provide further information for allure reports
18+
*
19+
* @package Magento\FunctionalTestingFramework\Allure
20+
*/
21+
22+
class MagentoAllureAdapter extends AllureAdapter
23+
{
24+
/**
25+
* Variable name used for extracting group argument to codecept run commaned
26+
*
27+
* @var string
28+
*/
29+
protected $groupKey = "groups";
30+
31+
/**
32+
* Array of group values from test runner command to append to allure suitename
33+
*
34+
* @var array
35+
*/
36+
protected $groups;
37+
38+
/**
39+
* Initialize from parent with group value
40+
*
41+
* @params array $ignoredAnnotations
42+
* @return AllureAdapter
43+
*/
44+
public function _initialize(array $ignoredAnnotations = [])
45+
{
46+
$this->groups = $this->getGroup($this->groupKey);
47+
parent::_initialize($ignoredAnnotations);
48+
}
49+
50+
/**
51+
* Array of group values passed to test runner command
52+
*
53+
* @param String $groupKey
54+
* @return array
55+
*/
56+
private function getGroup($groupKey)
57+
{
58+
$groups = $this->options[$groupKey];
59+
return $groups;
60+
}
61+
62+
/**
63+
* Override of parent method to set suitename as suitename and group name concatenated
64+
*
65+
* @param SuiteEvent $suiteEvent
66+
* @return void
67+
*/
68+
public function suiteBefore(SuiteEvent $suiteEvent)
69+
{
70+
$suite = $suiteEvent->getSuite();
71+
$group = implode(".", $this->groups);
72+
$suiteName = ($suite->getName())."-{$group}";
73+
//cant access protected property of suiteEvent
74+
//$suiteEvent->suite['name'] = $suiteName;
75+
76+
call_user_func(\Closure::bind(
77+
function () use ($suite, $suiteName) {
78+
$suite->name = $suiteName;
79+
},
80+
null,
81+
$suite
82+
));
83+
84+
$event = new TestSuiteStartedEvent($suiteName);
85+
if (class_exists($suiteName, false)) {
86+
$annotationManager = new Annotation\AnnotationManager(
87+
Annotation\AnnotationProvider::getClassAnnotations($suiteName)
88+
);
89+
$annotationManager->updateTestSuiteEvent($event);
90+
}
91+
$this->uuid = $event->getUuid();
92+
$this->getLifecycle()->fire($event);
93+
// unset($event);
94+
}
95+
96+
97+
public function suiteAfter()
98+
}
99+

0 commit comments

Comments
 (0)