From 32474b41a51ea058ad259071b44ec091ac8fbe80 Mon Sep 17 00:00:00 2001 From: Alexander Vladimirov Date: Thu, 7 Jan 2016 23:50:54 +0200 Subject: [PATCH] Update for Codeception 2.1 --- composer.json | 2 +- src/Yandex/Allure/Adapter/AllureAdapter.php | 36 ++++++++++++++++----- 2 files changed, 29 insertions(+), 9 deletions(-) diff --git a/composer.json b/composer.json index 03d76f8..1a77908 100644 --- a/composer.json +++ b/composer.json @@ -17,7 +17,7 @@ }, "require": { "php": ">=5.4.0", - "codeception/codeception": "~2.0.0", + "codeception/codeception": "~2.1.0", "allure-framework/allure-php-api": "~1.1.0", "symfony/filesystem": "~2.6", "symfony/finder": "~2.6" diff --git a/src/Yandex/Allure/Adapter/AllureAdapter.php b/src/Yandex/Allure/Adapter/AllureAdapter.php index 8298cec..a5f184c 100644 --- a/src/Yandex/Allure/Adapter/AllureAdapter.php +++ b/src/Yandex/Allure/Adapter/AllureAdapter.php @@ -50,14 +50,36 @@ class AllureAdapter extends Extension Events::TEST_SKIPPED => 'testSkipped', Events::TEST_END => 'testEnd', Events::STEP_BEFORE => 'stepBefore', - Events::STEP_FAIL => 'stepFail', Events::STEP_AFTER => 'stepAfter' ]; - public function _initialize() + /** + * Annotations that should be ignored by the annotaions parser (especially PHPUnit annotations). + * + * @var array + */ + private $ignoredAnnotations = [ + 'after', 'afterClass', 'backupGlobals', 'backupStaticAttributes', 'before', 'beforeClass', + 'codeCoverageIgnore', 'codeCoverageIgnoreStart', 'codeCoverageIgnoreEnd', 'covers', + 'coversDefaultClass', 'coversNothing', 'dataProvider', 'depends', 'expectedException', + 'expectedExceptionCode', 'expectedExceptionMessage', 'group', 'large', 'medium', + 'preserveGlobalState', 'requires', 'runTestsInSeparateProcesses', 'runInSeparateProcess', + 'small', 'test', 'testdox', 'ticket', 'uses', + ]; + + /** + * Extra annotations to ignore in addition to standard PHPUnit annotations. + * + * @param array $ignoredAnnotations + */ + public function _initialize(array $ignoredAnnotations = []) { parent::_initialize(); Annotation\AnnotationProvider::registerAnnotationNamespaces(); + // Add standard PHPUnit annotations + Annotation\AnnotationProvider::addIgnoredAnnotations($this->ignoredAnnotations); + // Add custom ignored annotations + Annotation\AnnotationProvider::addIgnoredAnnotations($ignoredAnnotations); $outputDirectory = $this->getOutputDirectory(); $deletePreviousResults = $this->tryGetOption(DELETE_PREVIOUS_RESULTS_PARAMETER, false); @@ -156,8 +178,10 @@ public function suiteBefore(SuiteEvent $suiteEvent) $suite = $suiteEvent->getSuite(); $suiteName = $suite->getName(); $event = new TestSuiteStartedEvent($suiteName); - if (class_exists($suiteName)){ - $annotationManager = new Annotation\AnnotationManager(Annotation\AnnotationProvider::getClassAnnotations(get_class($suite))); + if (class_exists($suiteName, false)) { + $annotationManager = new Annotation\AnnotationManager( + Annotation\AnnotationProvider::getClassAnnotations($suiteName) + ); $annotationManager->updateTestSuiteEvent($event); } $this->uuid = $event->getUuid(); @@ -218,10 +242,6 @@ public function stepAfter() $this->getLifecycle()->fire(new StepFinishedEvent()); } - public function stepFail() - { - $this->getLifecycle()->fire(new StepFailedEvent()); - } /** * @return Allure