From dcd1eca241627b2fd23206d8c0dc22754908b149 Mon Sep 17 00:00:00 2001 From: Tom Erskine Date: Wed, 28 Mar 2018 14:19:59 -0500 Subject: [PATCH 1/7] MQE-783: Allure reporting Spike - semi working solution --- .../Allure/Adapter/MagentoAllureAdapter.php | 99 +++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 src/Magento/FunctionalTestingFramework/Allure/Adapter/MagentoAllureAdapter.php diff --git a/src/Magento/FunctionalTestingFramework/Allure/Adapter/MagentoAllureAdapter.php b/src/Magento/FunctionalTestingFramework/Allure/Adapter/MagentoAllureAdapter.php new file mode 100644 index 000000000..912309b55 --- /dev/null +++ b/src/Magento/FunctionalTestingFramework/Allure/Adapter/MagentoAllureAdapter.php @@ -0,0 +1,99 @@ +groups = $this->getGroup($this->groupKey); + parent::_initialize($ignoredAnnotations); + } + + /** + * Array of group values passed to test runner command + * + * @param String $groupKey + * @return array + */ + private function getGroup($groupKey) + { + $groups = $this->options[$groupKey]; + return $groups; + } + + /** + * Override of parent method to set suitename as suitename and group name concatenated + * + * @param SuiteEvent $suiteEvent + * @return void + */ + public function suiteBefore(SuiteEvent $suiteEvent) + { + $suite = $suiteEvent->getSuite(); + $group = implode(".", $this->groups); + $suiteName = ($suite->getName())."-{$group}"; + //cant access protected property of suiteEvent + //$suiteEvent->suite['name'] = $suiteName; + + call_user_func(\Closure::bind( + function () use ($suite, $suiteName) { + $suite->name = $suiteName; + }, + null, + $suite + )); + + $event = new TestSuiteStartedEvent($suiteName); + if (class_exists($suiteName, false)) { + $annotationManager = new Annotation\AnnotationManager( + Annotation\AnnotationProvider::getClassAnnotations($suiteName) + ); + $annotationManager->updateTestSuiteEvent($event); + } + $this->uuid = $event->getUuid(); + $this->getLifecycle()->fire($event); + // unset($event); + } + + + public function suiteAfter() +} + From 78bc14425ad17a7dfb54ef58129933104bef1eab Mon Sep 17 00:00:00 2001 From: Tom Erskine Date: Wed, 28 Mar 2018 15:52:20 -0500 Subject: [PATCH 2/7] MQE-783 working prototype --- .../Allure/Adapter/MagentoAllureAdapter.php | 46 ++++++++++++++----- 1 file changed, 35 insertions(+), 11 deletions(-) diff --git a/src/Magento/FunctionalTestingFramework/Allure/Adapter/MagentoAllureAdapter.php b/src/Magento/FunctionalTestingFramework/Allure/Adapter/MagentoAllureAdapter.php index 912309b55..c551cad84 100644 --- a/src/Magento/FunctionalTestingFramework/Allure/Adapter/MagentoAllureAdapter.php +++ b/src/Magento/FunctionalTestingFramework/Allure/Adapter/MagentoAllureAdapter.php @@ -21,6 +21,8 @@ class MagentoAllureAdapter extends AllureAdapter { + private $uuid; + /** * Variable name used for extracting group argument to codecept run commaned * @@ -81,19 +83,41 @@ function () use ($suite, $suiteName) { $suite )); - $event = new TestSuiteStartedEvent($suiteName); - if (class_exists($suiteName, false)) { - $annotationManager = new Annotation\AnnotationManager( - Annotation\AnnotationProvider::getClassAnnotations($suiteName) - ); - $annotationManager->updateTestSuiteEvent($event); - } - $this->uuid = $event->getUuid(); - $this->getLifecycle()->fire($event); - // unset($event); + //change suiteEvent + $changeSuiteEvent = new SuiteEvent( + $suiteEvent->getSuite(), + $suiteEvent->getResult(), + $suiteEvent->getSettings() + ); + + // call parent function + parent::suiteBefore($changeSuiteEvent); +// +// $event = new TestSuiteStartedEvent($suiteName); +// if (class_exists($suiteName, false)) { +// $annotationManager = new Annotation\AnnotationManager( +// Annotation\AnnotationProvider::getClassAnnotations($suiteName) +// ); +// $annotationManager->updateTestSuiteEvent($event); +// } +// +//// $uuid = ""; +// $uuid = call_user_func(\Closure::bind( +// function () use ($uuid, $event) { +// return $this->uuid; +// }, +// null, +// $this +// )); +//// $this->uuid = $uuid; +// +// $this->uuid = $event->getUuid(); +// +// +// $this->getLifecycle()->fire($event); +// // unset($event); } - public function suiteAfter() } From 856aa5eae10289008a8982c2e4fe87e31d2c187d Mon Sep 17 00:00:00 2001 From: Tom Erskine Date: Thu, 29 Mar 2018 09:49:10 -0500 Subject: [PATCH 3/7] MQE-783: removing comments and whitespace --- .../Allure/Adapter/MagentoAllureAdapter.php | 31 ------------------- 1 file changed, 31 deletions(-) diff --git a/src/Magento/FunctionalTestingFramework/Allure/Adapter/MagentoAllureAdapter.php b/src/Magento/FunctionalTestingFramework/Allure/Adapter/MagentoAllureAdapter.php index c551cad84..f84e202ce 100644 --- a/src/Magento/FunctionalTestingFramework/Allure/Adapter/MagentoAllureAdapter.php +++ b/src/Magento/FunctionalTestingFramework/Allure/Adapter/MagentoAllureAdapter.php @@ -6,9 +6,6 @@ namespace Magento\FunctionalTestingFramework\Allure\Adapter; use Yandex\Allure\Adapter\AllureAdapter; -use Yandex\Allure\Adapter\Annotation; -use Yandex\Allure\Adapter\Event\TestSuiteEvent; -use Yandex\Allure\Adapter\Event\TestSuiteStartedEvent; use Codeception\Event\SuiteEvent; /** @@ -21,8 +18,6 @@ class MagentoAllureAdapter extends AllureAdapter { - private $uuid; - /** * Variable name used for extracting group argument to codecept run commaned * @@ -72,8 +67,6 @@ public function suiteBefore(SuiteEvent $suiteEvent) $suite = $suiteEvent->getSuite(); $group = implode(".", $this->groups); $suiteName = ($suite->getName())."-{$group}"; - //cant access protected property of suiteEvent - //$suiteEvent->suite['name'] = $suiteName; call_user_func(\Closure::bind( function () use ($suite, $suiteName) { @@ -92,30 +85,6 @@ function () use ($suite, $suiteName) { // call parent function parent::suiteBefore($changeSuiteEvent); -// -// $event = new TestSuiteStartedEvent($suiteName); -// if (class_exists($suiteName, false)) { -// $annotationManager = new Annotation\AnnotationManager( -// Annotation\AnnotationProvider::getClassAnnotations($suiteName) -// ); -// $annotationManager->updateTestSuiteEvent($event); -// } -// -//// $uuid = ""; -// $uuid = call_user_func(\Closure::bind( -// function () use ($uuid, $event) { -// return $this->uuid; -// }, -// null, -// $this -// )); -//// $this->uuid = $uuid; -// -// $this->uuid = $event->getUuid(); -// -// -// $this->getLifecycle()->fire($event); -// // unset($event); } From 5c426c89bc19aaa737efefcf7a27afdd03686719 Mon Sep 17 00:00:00 2001 From: Tom Erskine Date: Mon, 2 Apr 2018 09:38:18 -0500 Subject: [PATCH 4/7] MQE-783: [SPIKE] Investigate allure reporting when tests run in multiple suites - Cleaned up static check failures --- .../Allure/Adapter/MagentoAllureAdapter.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Magento/FunctionalTestingFramework/Allure/Adapter/MagentoAllureAdapter.php b/src/Magento/FunctionalTestingFramework/Allure/Adapter/MagentoAllureAdapter.php index f84e202ce..343b1f6fc 100644 --- a/src/Magento/FunctionalTestingFramework/Allure/Adapter/MagentoAllureAdapter.php +++ b/src/Magento/FunctionalTestingFramework/Allure/Adapter/MagentoAllureAdapter.php @@ -35,14 +35,17 @@ class MagentoAllureAdapter extends AllureAdapter /** * Initialize from parent with group value * - * @params array $ignoredAnnotations - * @return AllureAdapter + * @param array $ignoredAnnotations + * @return void */ + + // @codingStandardsIgnoreStart public function _initialize(array $ignoredAnnotations = []) { $this->groups = $this->getGroup($this->groupKey); parent::_initialize($ignoredAnnotations); } + // @codingStandardsIgnoreEnd /** * Array of group values passed to test runner command @@ -86,7 +89,4 @@ function () use ($suite, $suiteName) { // call parent function parent::suiteBefore($changeSuiteEvent); } - - } - From d48a35bd5e781b8dee8d6df2e326c182702db113 Mon Sep 17 00:00:00 2001 From: Tom Erskine Date: Tue, 3 Apr 2018 09:52:40 -0500 Subject: [PATCH 5/7] MQE-783: [SPIKE] Investigate allure reporting when tests run in multiple suites - Added null checking for test runs without group argument - Refactored suiteBefore in light of the above --- .../Allure/Adapter/MagentoAllureAdapter.php | 47 ++++++++++--------- 1 file changed, 26 insertions(+), 21 deletions(-) diff --git a/src/Magento/FunctionalTestingFramework/Allure/Adapter/MagentoAllureAdapter.php b/src/Magento/FunctionalTestingFramework/Allure/Adapter/MagentoAllureAdapter.php index 343b1f6fc..8ecfcb3e3 100644 --- a/src/Magento/FunctionalTestingFramework/Allure/Adapter/MagentoAllureAdapter.php +++ b/src/Magento/FunctionalTestingFramework/Allure/Adapter/MagentoAllureAdapter.php @@ -5,6 +5,7 @@ */ namespace Magento\FunctionalTestingFramework\Allure\Adapter; +use Magento\FunctionalTestingFramework\Data\Argument\Interpreter\NullType; use Yandex\Allure\Adapter\AllureAdapter; use Codeception\Event\SuiteEvent; @@ -30,7 +31,7 @@ class MagentoAllureAdapter extends AllureAdapter * * @var array */ - protected $groups; + protected $group; /** * Initialize from parent with group value @@ -42,7 +43,7 @@ class MagentoAllureAdapter extends AllureAdapter // @codingStandardsIgnoreStart public function _initialize(array $ignoredAnnotations = []) { - $this->groups = $this->getGroup($this->groupKey); + $this->group = $this->getGroup($this->groupKey); parent::_initialize($ignoredAnnotations); } // @codingStandardsIgnoreEnd @@ -51,12 +52,14 @@ public function _initialize(array $ignoredAnnotations = []) * Array of group values passed to test runner command * * @param String $groupKey - * @return array + * @return String */ private function getGroup($groupKey) { - $groups = $this->options[$groupKey]; - return $groups; + if(!($this->options[$groupKey] == Null)){ + return $this->options[$groupKey][0]; + } + return null; } /** @@ -67,25 +70,27 @@ private function getGroup($groupKey) */ public function suiteBefore(SuiteEvent $suiteEvent) { - $suite = $suiteEvent->getSuite(); - $group = implode(".", $this->groups); - $suiteName = ($suite->getName())."-{$group}"; + $changeSuiteEvent = $suiteEvent; - call_user_func(\Closure::bind( - function () use ($suite, $suiteName) { - $suite->name = $suiteName; - }, - null, - $suite - )); + if ($this->group != null) { + $suite = $suiteEvent->getSuite(); + $suiteName = ($suite->getName()) . "-{$this->group}"; - //change suiteEvent - $changeSuiteEvent = new SuiteEvent( - $suiteEvent->getSuite(), - $suiteEvent->getResult(), - $suiteEvent->getSettings() - ); + call_user_func(\Closure::bind( + function () use ($suite, $suiteName) { + $suite->name = $suiteName; + }, + null, + $suite + )); + //change suiteEvent + $changeSuiteEvent = new SuiteEvent( + $suiteEvent->getSuite(), + $suiteEvent->getResult(), + $suiteEvent->getSettings() + ); + } // call parent function parent::suiteBefore($changeSuiteEvent); } From df9dfda6ae507cbfead43db4e525aa29745d14b6 Mon Sep 17 00:00:00 2001 From: Tom Erskine Date: Wed, 4 Apr 2018 10:22:12 -0500 Subject: [PATCH 6/7] MQE-783: [SPIKE] Investigate allure reporting when tests run in multiple suites - Updated MagentoAllureAdapter to remove instance varaibles and hardcode the groupKey to 'groups' as this will not change --- .../Allure/Adapter/MagentoAllureAdapter.php | 40 +++---------------- 1 file changed, 5 insertions(+), 35 deletions(-) diff --git a/src/Magento/FunctionalTestingFramework/Allure/Adapter/MagentoAllureAdapter.php b/src/Magento/FunctionalTestingFramework/Allure/Adapter/MagentoAllureAdapter.php index 8ecfcb3e3..bdc57e4f0 100644 --- a/src/Magento/FunctionalTestingFramework/Allure/Adapter/MagentoAllureAdapter.php +++ b/src/Magento/FunctionalTestingFramework/Allure/Adapter/MagentoAllureAdapter.php @@ -19,45 +19,15 @@ class MagentoAllureAdapter extends AllureAdapter { - /** - * Variable name used for extracting group argument to codecept run commaned - * - * @var string - */ - protected $groupKey = "groups"; - - /** - * Array of group values from test runner command to append to allure suitename - * - * @var array - */ - protected $group; - - /** - * Initialize from parent with group value - * - * @param array $ignoredAnnotations - * @return void - */ - - // @codingStandardsIgnoreStart - public function _initialize(array $ignoredAnnotations = []) - { - $this->group = $this->getGroup($this->groupKey); - parent::_initialize($ignoredAnnotations); - } - // @codingStandardsIgnoreEnd - /** * Array of group values passed to test runner command * - * @param String $groupKey * @return String */ - private function getGroup($groupKey) + private function getGroup() { - if(!($this->options[$groupKey] == Null)){ - return $this->options[$groupKey][0]; + if ($this->options['groups'] != null) { + return $this->options['groups'][0]; } return null; } @@ -72,9 +42,9 @@ public function suiteBefore(SuiteEvent $suiteEvent) { $changeSuiteEvent = $suiteEvent; - if ($this->group != null) { + if ($this->getGroup() != null) { $suite = $suiteEvent->getSuite(); - $suiteName = ($suite->getName()) . "-{$this->group}"; + $suiteName = ($suite->getName()) . "-{$this->getGroup()}"; call_user_func(\Closure::bind( function () use ($suite, $suiteName) { From d3db491ba0410d2814609d72aa4de435356c77a3 Mon Sep 17 00:00:00 2001 From: Ian Meron Date: Thu, 5 Apr 2018 11:42:54 -0500 Subject: [PATCH 7/7] MQE-783: [SPIKE] Investigate allure reporting when tests run in multiple suites - change suiteName to be of format \ --- .../Allure/Adapter/MagentoAllureAdapter.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Magento/FunctionalTestingFramework/Allure/Adapter/MagentoAllureAdapter.php b/src/Magento/FunctionalTestingFramework/Allure/Adapter/MagentoAllureAdapter.php index bdc57e4f0..c10a04506 100644 --- a/src/Magento/FunctionalTestingFramework/Allure/Adapter/MagentoAllureAdapter.php +++ b/src/Magento/FunctionalTestingFramework/Allure/Adapter/MagentoAllureAdapter.php @@ -44,7 +44,7 @@ public function suiteBefore(SuiteEvent $suiteEvent) if ($this->getGroup() != null) { $suite = $suiteEvent->getSuite(); - $suiteName = ($suite->getName()) . "-{$this->getGroup()}"; + $suiteName = ($suite->getName()) . "\\" . $this->getGroup(); call_user_func(\Closure::bind( function () use ($suite, $suiteName) {