Search in sources :

Example 1 with AnnotationManager

use of ru.yandex.qatools.allure.utils.AnnotationManager in project allure-cucumberjvm by allure-framework.

the class AllureReporter method startOfScenarioLifeCycle.

@Override
public void startOfScenarioLifeCycle(Scenario scenario) {
    //to avoid duplicate steps in case of Scenario Outline
    if (SCENARIO_OUTLINE_KEYWORDS.contains(scenario.getKeyword())) {
        synchronized (gherkinSteps) {
            gherkinSteps.clear();
        }
    }
    currentStatus = PASSED;
    TestCaseStartedEvent event = new TestCaseStartedEvent(uid, scenario.getName());
    event.setTitle(scenario.getName());
    Collection<Annotation> annotations = new ArrayList<>();
    SeverityLevel level = getSeverityLevel(scenario);
    if (level != null) {
        annotations.add(getSeverityAnnotation(level));
    }
    Issues issues = getIssuesAnnotation(scenario);
    if (issues != null) {
        annotations.add(issues);
    }
    TestCaseId testCaseId = getTestCaseIdAnnotation(scenario);
    if (testCaseId != null) {
        annotations.add(testCaseId);
    }
    annotations.add(getFeaturesAnnotation(feature.getName()));
    annotations.add(getStoriesAnnotation(scenario.getName()));
    annotations.add(getDescriptionAnnotation(scenario.getDescription()));
    AnnotationManager am = new AnnotationManager(annotations);
    am.update(event);
    event.withLabels(AllureModelUtils.createTestFrameworkLabel("CucumberJVM"));
    ALLURE_LIFECYCLE.fire(event);
}
Also used : AnnotationManager(ru.yandex.qatools.allure.utils.AnnotationManager) SeverityLevel(ru.yandex.qatools.allure.model.SeverityLevel) Issues(ru.yandex.qatools.allure.annotations.Issues) ArrayList(java.util.ArrayList) TestCaseId(ru.yandex.qatools.allure.annotations.TestCaseId) Annotation(java.lang.annotation.Annotation)

Example 2 with AnnotationManager

use of ru.yandex.qatools.allure.utils.AnnotationManager in project allure-cucumberjvm by allure-framework.

the class AllureRunListener method testStarted.

@Override
public void testStarted(Description description) throws IllegalAccessException {
    if (description.isTest()) {
        String methodName = extractMethodName(description);
        TestCaseStartedEvent event = new TestCaseStartedEvent(getSuiteUid(description), methodName);
        event.setTitle(methodName);
        Collection<Annotation> annotations = new ArrayList<>();
        for (Annotation annotation : description.getAnnotations()) {
            annotations.add(annotation);
        }
        AnnotationManager am = new AnnotationManager(annotations);
        am.update(event);
        getLifecycle().fire(event);
    }
}
Also used : AnnotationManager(ru.yandex.qatools.allure.utils.AnnotationManager) ArrayList(java.util.ArrayList) Annotation(java.lang.annotation.Annotation) TestCaseStartedEvent(ru.yandex.qatools.allure.events.TestCaseStartedEvent)

Example 3 with AnnotationManager

use of ru.yandex.qatools.allure.utils.AnnotationManager in project allure-cucumberjvm by allure-framework.

the class AllureRunListener method testSuiteStarted.

public void testSuiteStarted(Description description, String suiteName) throws IllegalAccessException {
    String[] annotationParams = findFeatureByScenarioName(suiteName);
    //Create feature and story annotations. Remove unnecessary words from it
    Features feature = getFeaturesAnnotation(new String[] { annotationParams[0].split(":")[1].trim() });
    Stories story = getStoriesAnnotation(new String[] { annotationParams[1].split(":")[1].trim() });
    //If it`s Scenario Outline, add example string to story name
    if (description.getDisplayName().startsWith("|") || description.getDisplayName().endsWith("|")) {
        story = getStoriesAnnotation(new String[] { annotationParams[1].split(":")[1].trim() + " " + description.getDisplayName() });
    }
    String uid = generateSuiteUid(suiteName);
    TestSuiteStartedEvent event = new TestSuiteStartedEvent(uid, story.value()[0]);
    event.setTitle(story.value()[0]);
    //Add feature and story annotations
    Collection<Annotation> annotations = new ArrayList<>();
    for (Annotation annotation : description.getAnnotations()) {
        annotations.add(annotation);
    }
    annotations.add(story);
    annotations.add(feature);
    AnnotationManager am = new AnnotationManager(annotations);
    am.update(event);
    event.withLabels(AllureModelUtils.createTestFrameworkLabel("CucumberJVM"));
    getLifecycle().fire(event);
}
Also used : AnnotationManager(ru.yandex.qatools.allure.utils.AnnotationManager) TestSuiteStartedEvent(ru.yandex.qatools.allure.events.TestSuiteStartedEvent) ArrayList(java.util.ArrayList) Features(ru.yandex.qatools.allure.annotations.Features) Stories(ru.yandex.qatools.allure.annotations.Stories) Annotation(java.lang.annotation.Annotation)

Example 4 with AnnotationManager

use of ru.yandex.qatools.allure.utils.AnnotationManager in project allure-cucumberjvm by allure-framework.

the class AllureRunListener method startFakeTestCase.

public void startFakeTestCase(Description description) throws IllegalAccessException {
    String uid = getSuiteUid(description);
    String name = description.isTest() ? description.getMethodName() : description.getClassName();
    TestCaseStartedEvent event = new TestCaseStartedEvent(uid, name);
    event.setTitle(name);
    AnnotationManager am = new AnnotationManager(description.getAnnotations());
    am.update(event);
    getLifecycle().fire(event);
}
Also used : AnnotationManager(ru.yandex.qatools.allure.utils.AnnotationManager) TestCaseStartedEvent(ru.yandex.qatools.allure.events.TestCaseStartedEvent)

Example 5 with AnnotationManager

use of ru.yandex.qatools.allure.utils.AnnotationManager in project allure-cucumberjvm by allure-framework.

the class AllureReporter method feature.

@Override
public void feature(Feature feature) {
    this.feature = feature;
    uid = UUID.randomUUID().toString();
    TestSuiteStartedEvent event = new TestSuiteStartedEvent(uid, feature.getName());
    Collection<Annotation> annotations = new ArrayList<>();
    annotations.add(getDescriptionAnnotation(feature.getDescription()));
    annotations.add(getFeaturesAnnotation(feature.getName()));
    AnnotationManager am = new AnnotationManager(annotations);
    am.update(event);
    ALLURE_LIFECYCLE.fire(event);
}
Also used : AnnotationManager(ru.yandex.qatools.allure.utils.AnnotationManager) ArrayList(java.util.ArrayList) Annotation(java.lang.annotation.Annotation)

Aggregations

AnnotationManager (ru.yandex.qatools.allure.utils.AnnotationManager)5 Annotation (java.lang.annotation.Annotation)4 ArrayList (java.util.ArrayList)4 TestCaseStartedEvent (ru.yandex.qatools.allure.events.TestCaseStartedEvent)2 Features (ru.yandex.qatools.allure.annotations.Features)1 Issues (ru.yandex.qatools.allure.annotations.Issues)1 Stories (ru.yandex.qatools.allure.annotations.Stories)1 TestCaseId (ru.yandex.qatools.allure.annotations.TestCaseId)1 TestSuiteStartedEvent (ru.yandex.qatools.allure.events.TestSuiteStartedEvent)1 SeverityLevel (ru.yandex.qatools.allure.model.SeverityLevel)1