public function updateTestSuiteEvent(TestSuiteStartedEvent $event) { if ($this->isTitlePresent()) { $event->setTitle($this->getTitle()); } if ($this->isDescriptionPresent()) { $event->setDescription($this->getDescription()); } if ($this->areLabelsPresent()) { $event->setLabels($this->getLabels()); } }
private function generateXML($tmpDir) { AnnotationRegistry::registerAutoloadNamespace('JMS\\Serializer\\Annotation', __DIR__ . "/../../../../vendor/jms/serializer/src"); Model\Provider::setOutputDirectory($tmpDir); Allure::setDefaultLifecycle(); $testSuiteStartedEvent = new TestSuiteStartedEvent(TEST_SUITE_NAME); $uuid = $testSuiteStartedEvent->getUuid(); $testSuiteStartedEvent->setTitle(TEST_SUITE_TITLE); $testSuiteStartedEvent->setDescription(new Description(DescriptionType::HTML, DESCRIPTION)); $testSuiteStartedEvent->setLabels([Label::feature(FEATURE_NAME), Label::story(STORY_NAME)]); Allure::lifecycle()->fire($testSuiteStartedEvent); $testCaseStartedEvent = new TestCaseStartedEvent($uuid, TEST_CASE_NAME); $testCaseStartedEvent->setDescription(new Description(DescriptionType::MARKDOWN, DESCRIPTION)); $testCaseStartedEvent->setLabels([Label::feature(FEATURE_NAME), Label::story(STORY_NAME), Label::severity(SeverityLevel::MINOR)]); $testCaseStartedEvent->setTitle(TEST_CASE_TITLE); $testCaseStartedEvent->setParameters([new Parameter(PARAMETER_NAME, PARAMETER_VALUE, ParameterKind::SYSTEM_PROPERTY)]); Allure::lifecycle()->fire($testCaseStartedEvent); $testCaseFailureEvent = new TestCaseFailedEvent(); $testCaseFailureEvent = $testCaseFailureEvent->withMessage(FAILURE_MESSAGE)->withException(new \Exception()); Allure::lifecycle()->fire($testCaseFailureEvent); $stepStartedEvent = new StepStartedEvent(STEP_NAME); $stepStartedEvent = $stepStartedEvent->withTitle(STEP_TITLE); Allure::lifecycle()->fire($stepStartedEvent); Allure::lifecycle()->fire(new AddAttachmentEvent(STEP_ATTACHMENT_SOURCE, STEP_ATTACHMENT_TITLE, 'text/plain')); Allure::lifecycle()->fire(new StepFinishedEvent()); Allure::lifecycle()->fire(new TestCaseFinishedEvent()); Allure::lifecycle()->fire(new TestSuiteFinishedEvent($uuid)); return $uuid; }
public function testEvent() { $testSuite = new TestSuite(); $testSuiteName = 'test-suite-name'; $testSuiteTitle = 'test-suite-title'; $testSuiteDescriptionValue = 'test-suite-description-value'; $testSuiteDescriptionType = DescriptionType::TEXT; $testSuiteLabelValue = 'test-suite-label-value'; $testSuiteLabelName = LabelType::STORY; $event = new TestSuiteStartedEvent($testSuiteName); $event->withTitle($testSuiteTitle)->withDescription(new Description($testSuiteDescriptionType, $testSuiteDescriptionValue))->withLabels(array(new Label($testSuiteLabelName, $testSuiteLabelValue))); $event->process($testSuite); $this->assertEquals($testSuiteTitle, $testSuite->getTitle()); $this->assertNotEmpty($testSuite->getStart()); $this->assertEquals($testSuiteName, $testSuite->getName()); $this->assertNotEmpty($testSuite->getDescription()); $this->assertEquals($testSuiteDescriptionValue, $testSuite->getDescription()->getValue()); $this->assertEquals($testSuiteDescriptionType, $testSuite->getDescription()->getType()); $this->assertEquals(1, sizeof($testSuite->getLabels())); $labels = $testSuite->getLabels(); $label = array_pop($labels); $this->assertTrue($label instanceof Label && $label->getName() === $testSuiteLabelName && $label->getValue() === $testSuiteLabelValue); $this->assertEmpty($testSuite->getStop()); }
/** * A test suite started. * * @param PHPUnit_Framework_TestSuite $suite * @since Method available since Release 2.2.0 */ public function startTestSuite(PHPUnit_Framework_TestSuite $suite) { if ($suite instanceof \PHPUnit_Framework_TestSuite_DataProvider) { return; } $suiteName = $suite->getName(); $event = new TestSuiteStartedEvent($suiteName); $this->uuid = $event->getUuid(); $this->suiteName = $suiteName; if (class_exists($suiteName, false)) { $annotationManager = new Annotation\AnnotationManager(Annotation\AnnotationProvider::getClassAnnotations($suiteName)); $annotationManager->updateTestSuiteEvent($event); } Allure::lifecycle()->fire($event); }