public function testUpdateTestCaseStartedEvent() { $instance = new Fixtures\ExampleTestSuite(); $testCaseAnnotations = AnnotationProvider::getMethodAnnotations($instance, 'exampleTestCase'); $annotationManager = new AnnotationManager($testCaseAnnotations); $event = new TestCaseStartedEvent('some-uid', 'some-name'); $annotationManager->updateTestCaseEvent($event); //Check scalar properties $this->assertEquals('test-case-title', $event->getTitle()); $this->assertEquals('test-case-description', $event->getDescription()->getValue()); $this->assertEquals(DescriptionType::HTML, $event->getDescription()->getType()); $this->assertEquals(7, sizeof($event->getLabels())); //Check feature presence $features = $this->getLabelsByType($event->getLabels(), LabelType::FEATURE); $this->assertEquals(2, sizeof($features)); $index = 1; foreach ($features as $feature) { $this->assertInstanceOf('Yandex\\Allure\\Adapter\\Model\\Label', $feature); $this->assertEquals("test-case-feature{$index}", $feature->getValue()); $index++; } //Check stories presence $stories = $this->getLabelsByType($event->getLabels(), LabelType::STORY); $this->assertEquals(2, sizeof($stories)); $index = 1; foreach ($stories as $story) { $this->assertInstanceOf('Yandex\\Allure\\Adapter\\Model\\Label', $story); $this->assertEquals("test-case-story{$index}", $story->getValue()); $index++; } //Check issues presence $issues = $this->getLabelsByType($event->getLabels(), LabelType::ISSUE); $this->assertEquals(2, sizeof($issues)); $index = 1; foreach ($issues as $issue) { $this->assertInstanceOf('Yandex\\Allure\\Adapter\\Model\\Label', $issue); $this->assertEquals("test-case-issue{$index}", $issue->getValue()); $index++; } //Check severity presence $severities = $this->getLabelsByType($event->getLabels(), LabelType::SEVERITY); $this->assertEquals(1, sizeof($severities)); $severity = array_pop($severities); $this->assertInstanceOf('Yandex\\Allure\\Adapter\\Model\\Label', $severity); $this->assertSame(SeverityLevel::BLOCKER, $severity->getValue()); //Check parameter presence $parameters = $event->getParameters(); $this->assertEquals(1, sizeof($parameters)); $parameter = array_pop($parameters); $this->assertInstanceOf('Yandex\\Allure\\Adapter\\Model\\Parameter', $parameter); $this->assertSame('test-case-param-name', $parameter->getName()); $this->assertSame('test-case-param-value', $parameter->getValue()); $this->assertSame(ParameterKind::ARGUMENT, $parameter->getKind()); }
/** * A test started. * * @param PHPUnit_Framework_Test $test */ public function startTest(PHPUnit_Framework_Test $test) { if ($test instanceof \PHPUnit_Framework_TestCase) { $testName = $test->getName(); $methodName = $this->methodName = $test->getName(false); $event = new TestCaseStartedEvent($this->uuid, $testName); if (method_exists($test, $methodName)) { $annotationManager = new Annotation\AnnotationManager(Annotation\AnnotationProvider::getMethodAnnotations(get_class($test), $methodName)); $annotationManager->updateTestCaseEvent($event); } Allure::lifecycle()->fire($event); } }
public function testStart(TestEvent $testEvent) { $test = $testEvent->getTest(); $testName = $test->getName(); $className = get_class($test); $event = new TestCaseStartedEvent($this->uuid, $testName); if (method_exists($className, $testName)) { $annotationManager = new Annotation\AnnotationManager(Annotation\AnnotationProvider::getMethodAnnotations($className, $testName)); $annotationManager->updateTestCaseEvent($event); } $this->getLifecycle()->fire($event); }