Search in sources :

Example 1 with SeverityLevel

use of ru.yandex.qatools.allure.model.SeverityLevel 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 SeverityLevel

use of ru.yandex.qatools.allure.model.SeverityLevel in project allure-cucumberjvm by allure-framework.

the class AllureReporter method getSeverityLevel.

private SeverityLevel getSeverityLevel(Scenario scenario) {
    SeverityLevel level = null;
    List<SeverityLevel> severityLevels = Arrays.asList(SeverityLevel.BLOCKER, SeverityLevel.CRITICAL, SeverityLevel.NORMAL, SeverityLevel.MINOR, SeverityLevel.TRIVIAL);
    for (Tag tag : scenario.getTags()) {
        Matcher matcher = SEVERITY_PATTERN.matcher(tag.getName());
        if (matcher.matches()) {
            SeverityLevel levelTmp;
            String levelString = matcher.group(1);
            try {
                levelTmp = SeverityLevel.fromValue(levelString.toLowerCase());
            } catch (IllegalArgumentException e) {
                LOG.warn(String.format("Unexpected Severity level [%s]. SeverityLevel.NORMAL will be used instead", levelString), e);
                levelTmp = SeverityLevel.NORMAL;
            }
            if (level == null || severityLevels.indexOf(levelTmp) < severityLevels.indexOf(level)) {
                level = levelTmp;
            }
        }
    }
    return level;
}
Also used : SeverityLevel(ru.yandex.qatools.allure.model.SeverityLevel) Matcher(java.util.regex.Matcher) Tag(gherkin.formatter.model.Tag)

Aggregations

SeverityLevel (ru.yandex.qatools.allure.model.SeverityLevel)2 Tag (gherkin.formatter.model.Tag)1 Annotation (java.lang.annotation.Annotation)1 ArrayList (java.util.ArrayList)1 Matcher (java.util.regex.Matcher)1 Issues (ru.yandex.qatools.allure.annotations.Issues)1 TestCaseId (ru.yandex.qatools.allure.annotations.TestCaseId)1 AnnotationManager (ru.yandex.qatools.allure.utils.AnnotationManager)1