Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/Yandex/Allure/Adapter/Annotation/AnnotationManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ private function processAnnotations(array $annotations)
$annotation->type,
$annotation->value
);
} elseif ($annotation instanceof Epics) {
foreach ($annotation->getEpicNames() as $epicName) {
$this->labels[] = Model\Label::epic($epicName);
}
} elseif ($annotation instanceof Features) {
foreach ($annotation->getFeatureNames() as $featureName) {
$this->labels[] = Model\Label::feature($featureName);
Expand Down
27 changes: 27 additions & 0 deletions src/Yandex/Allure/Adapter/Annotation/Epics.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

namespace Yandex\Allure\Adapter\Annotation;

use Doctrine\Common\Annotations\Annotation\Required;

/**
* @Annotation
* @Target({"CLASS", "METHOD"})
* @package Yandex\Allure\Adapter\Annotation
*/
class Epics
{
/**
* @var array
* @Required
*/
public $epicNames;

/**
* @return array
*/
public function getEpicNames()
{
return $this->epicNames;
}
}
10 changes: 10 additions & 0 deletions src/Yandex/Allure/Adapter/Model/Label.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,16 @@ public static function id($id)
{
return new Label(LabelType::ID, $id);
}

/**
* @param $epicName
* @return Label
*/
public static function epic($epicName)
{
return new Label(LabelType::EPIC, $epicName);
}

/**
* @param $featureName
* @return Label
Expand Down
1 change: 1 addition & 0 deletions src/Yandex/Allure/Adapter/Model/LabelType.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
class LabelType
{
const ID = 'AS_ID';
const EPIC = 'epic';
const FEATURE = 'feature';
const STORY = 'story';
const SEVERITY = 'severity';
Expand Down
28 changes: 24 additions & 4 deletions test/Yandex/Allure/Adapter/Annotation/AnnotationManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,17 @@ public function testUpdateTestSuiteStartedEvent()
$this->assertEquals('test-suite-title', $event->getTitle());
$this->assertEquals('test-suite-description', $event->getDescription()->getValue());
$this->assertEquals(DescriptionType::MARKDOWN, $event->getDescription()->getType());
$this->assertEquals(6, sizeof($event->getLabels()));
$this->assertEquals(8, sizeof($event->getLabels()));

//Check features presence
$epics = $this->getLabelsByType($event->getLabels(), LabelType::EPIC);
$this->assertEquals(2, sizeof($epics));
$index = 1;
foreach ($epics as $epic) {
$this->assertInstanceOf('Yandex\Allure\Adapter\Model\Label', $epic);
$this->assertEquals("test-suite-epic$index", $epic->getValue());
$index++;
}

//Check features presence
$features = $this->getLabelsByType($event->getLabels(), LabelType::FEATURE);
Expand Down Expand Up @@ -69,7 +79,7 @@ public function testUpdateTestCaseStartedEvent()
$this->assertEquals('test-case-title', $event->getTitle());
$this->assertEquals('test-case-description', $event->getDescription()->getValue());
$this->assertEquals(DescriptionType::HTML, $event->getDescription()->getType());
$this->assertEquals(10, sizeof($event->getLabels()));
$this->assertEquals(12, sizeof($event->getLabels()));

//Check id presence
$ids = $this->getLabelsByType($event->getLabels(), LabelType::ID);
Expand All @@ -78,6 +88,16 @@ public function testUpdateTestCaseStartedEvent()
$this->assertInstanceOf('Yandex\Allure\Adapter\Model\Label', $id);
$this->assertSame("123", $id->getValue());

//Check epic presence
$epics = $this->getLabelsByType($event->getLabels(), LabelType::EPIC);
$this->assertEquals(2, sizeof($epics));
$index = 1;
foreach ($epics as $epic) {
$this->assertInstanceOf('Yandex\Allure\Adapter\Model\Label', $epic);
$this->assertEquals("test-case-epic$index", $epic->getValue());
$index++;
}

//Check feature presence
$features = $this->getLabelsByType($event->getLabels(), LabelType::FEATURE);
$this->assertEquals(2, sizeof($features));
Expand All @@ -97,7 +117,7 @@ public function testUpdateTestCaseStartedEvent()
$this->assertEquals("test-case-story$index", $story->getValue());
$index++;
}

//Check issues presence
$issues = $this->getLabelsByType($event->getLabels(), LabelType::ISSUE);
$this->assertEquals(2, sizeof($issues));
Expand Down Expand Up @@ -143,7 +163,7 @@ public function testUpdateTestCaseStartedEvent()
*/
private function getLabelsByType(array $labels, $labelType)
{
$filteredArray = array_filter(
$filteredArray = array_filter(
$labels,
function ($element) use ($labelType) {
return ($element instanceof Label) && ($element->getName() === $labelType);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Yandex\Allure\Adapter\Annotation\Fixtures;

use Yandex\Allure\Adapter\Annotation\AllureId;
use Yandex\Allure\Adapter\Annotation\Epics;
use Yandex\Allure\Adapter\Annotation\Issues;
use Yandex\Allure\Adapter\Annotation\Title;
use Yandex\Allure\Adapter\Annotation\Description;
Expand All @@ -19,6 +20,7 @@
/**
* @Title("test-suite-title")
* @Description(value="test-suite-description", type=DescriptionType::MARKDOWN)
* @Epics({"test-suite-epic1", "test-suite-epic2"})
* @Features({"test-suite-feature1", "test-suite-feature2"})
* @Stories({"test-suite-story1", "test-suite-story2"})
* @Issues({"test-suite-issue1", "test-suite-issue2"})
Expand All @@ -29,6 +31,7 @@ class ExampleTestSuite
* @AllureId("123")
* @Title("test-case-title")
* @Description(value="test-case-description", type=DescriptionType::HTML)
* @Epics({"test-case-epic1", "test-case-epic2"})
* @Features({"test-case-feature1", "test-case-feature2"})
* @Stories({"test-case-story1", "test-case-story2"})
* @Severity(SeverityLevel::BLOCKER)
Expand Down