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; }
private function processAnnotations(array $annotations) { foreach ($annotations as $annotation) { if ($annotation instanceof Title) { $this->title = $annotation->value; } elseif ($annotation instanceof Description) { $this->description = new Model\Description($annotation->type, $annotation->value); } elseif ($annotation instanceof Features) { foreach ($annotation->getFeatureNames() as $featureName) { $this->labels[] = Model\Label::feature($featureName); } } elseif ($annotation instanceof Stories) { foreach ($annotation->getStories() as $issueKey) { $this->labels[] = Model\Label::story($issueKey); } } elseif ($annotation instanceof Issues) { foreach ($annotation->getIssueKeys() as $issueKey) { $this->labels[] = Model\Label::issue($issueKey); } } elseif ($annotation instanceof Severity) { $this->labels[] = Model\Label::severity(ConstantChecker::validate('Yandex\\Allure\\Adapter\\Model\\SeverityLevel', $annotation->level)); } elseif ($annotation instanceof Parameter) { $this->parameters[] = new Model\Parameter($annotation->name, $annotation->value, $annotation->kind); } } }