ru.yandex.qatools.allure.model.SeverityLevel Java Examples

The following examples show how to use ru.yandex.qatools.allure.model.SeverityLevel. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Allure1TestCaseAspectsTest.java    From allure-java with Apache License 2.0 6 votes vote down vote up
@ParameterizedTest
@MethodSource("testClassesProvider")
void shouldProcessSeverityAnnotation(final SimpleTest simpleTest) {
    final AllureResults results = runWithinTestContext(
            simpleTest::testSomething,
            Allure1TestCaseAspects::setLifecycle,
            Allure1ParametersAspects::setLifecycle
    );

    assertThat(results.getTestResults())
            .flatExtracting(TestResult::getLabels)
            .filteredOn(label -> label.getName().equals("severity"))
            .extracting(Label::getValue)
            .containsExactlyInAnyOrder(SeverityLevel.CRITICAL.value());

}
 
Example #2
Source File: AddPropertiesView.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
private ObservableList<String> getSeverity() {
    ObservableList<String> severities = FXCollections.observableArrayList();
    for (SeverityLevel severityLevel : SeverityLevel.values()) {
        severities.add(severityLevel.value());
    }
    return severities;
}
 
Example #3
Source File: AllureMarathonRunListener.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
@Override
public void testStarted(Description description) {
    TestCaseStartedEvent event = new TestCaseStartedEvent(getSuiteUid(description), getTestName());

    SeverityLevel severityLevel = SeverityLevel.NORMAL;
    Properties testProperties = getTestProperties();
    String severity = testProperties.getProperty("severity");
    if (severity != null) {
        severityLevel = SeverityLevel.fromValue(severity);
    }
    event.getLabels().add(AllureModelUtils.createSeverityLabel(severityLevel));

    String desc = testProperties.getProperty("description");
    if (desc != null) {
        String dType = "text";
        if (desc.startsWith("html:")) {
            dType = "html";
            desc = desc.substring(5);
        } else if (desc.startsWith("markdown:")) {
            dType = "markdown";
            desc = desc.substring(9);
        }
        event.setDescription(
                new ru.yandex.qatools.allure.model.Description().withType(DescriptionType.fromValue(dType)).withValue(desc));
    }

    String id = testProperties.getProperty("id");
    if (id != null) {
        event.getLabels().add(AllureModelUtils.createTestLabel(id));
    }

    Path testPath = Paths.get(testProperties.getProperty("path", ""));
    addGroups(issues, event.getLabels(), testPath, LabelName.ISSUE);
    addGroups(features, event.getLabels(), testPath, LabelName.FEATURE);
    addGroups(stories, event.getLabels(), testPath, LabelName.STORY);
    getLifecycle().fire(event);
}
 
Example #4
Source File: Allure1TestCaseAspectsTest.java    From allure-java with Apache License 2.0 5 votes vote down vote up
@Title("testcase")
@Description("testcase description")
@Issue("ISSUE-2")
@Issues(@Issue("ISSUE-22"))
@TestCaseId("TEST-1")
@Stories("story2")
@Features("feature2")
@Severity(SeverityLevel.CRITICAL)
@org.testng.annotations.Test
public void testSomething() {
    parameterWithoutName = "testValue1";
    parameterWithName = "testValue2";
}
 
Example #5
Source File: Allure1TestCaseAspectsTest.java    From allure-java with Apache License 2.0 5 votes vote down vote up
@Title("testcase")
@Description("testcase description")
@Issue("ISSUE-2")
@Issues(@Issue("ISSUE-22"))
@TestCaseId("TEST-1")
@Stories("story2")
@Features("feature2")
@Severity(SeverityLevel.CRITICAL)
@org.junit.Test
public void testSomething() {
    parameterWithoutName = "testValue1";
    parameterWithName = "testValue2";
}
 
Example #6
Source File: AllureReporter.java    From allure-cucumberjvm with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example #7
Source File: AllureReporter.java    From allure-cucumberjvm with Apache License 2.0 5 votes vote down vote up
private Severity getSeverityAnnotation(final SeverityLevel value) {
    return new Severity() {

        @Override
        public SeverityLevel value() {
            return value;
        }

        @Override
        public Class<Severity> annotationType() {
            return Severity.class;
        }
    };
}
 
Example #8
Source File: SimpleClass.java    From allure1 with Apache License 2.0 5 votes vote down vote up
@Title("some.title")
@Description("some.description")
@Severity(SeverityLevel.BLOCKER)
@Features("some.feature")
@Stories("some.story")
@Issue("some.simple.issue")
@Issues({
    @Issue("some.nested.issue.1"),
    @Issue("some.nested.issue.2")
})
@TestCaseId("test.case.id")
public void simpleMethod() {
}
 
Example #9
Source File: AllureReporter.java    From allure-cucumberjvm with Apache License 2.0 4 votes vote down vote up
@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);
}
 
Example #10
Source File: AllureModelUtils.java    From allure1 with Apache License 2.0 4 votes vote down vote up
public static Label createSeverityLabel(SeverityLevel level) {
    return createLabel(LabelName.SEVERITY, level.value());
}
 
Example #11
Source File: AllureModelUtilsTest.java    From allure1 with Apache License 2.0 4 votes vote down vote up
@Test
public void createSeverityLabelTest() throws Exception {
    Label label = AllureModelUtils.createSeverityLabel(SeverityLevel.BLOCKER);
    assertThat(label.getValue(), is(SeverityLevel.BLOCKER.value()));
    assertThat(label.getName(), is(LabelName.SEVERITY.value()));
}
 
Example #12
Source File: SimpleClass.java    From allure1 with Apache License 2.0 4 votes vote down vote up
@Severity(SeverityLevel.CRITICAL)
@Issue("initial.issue")
public void combinedMethod(){
}
 
Example #13
Source File: AnnotationManager.java    From allure1 with Apache License 2.0 2 votes vote down vote up
/**
 * Find first {@link ru.yandex.qatools.allure.annotations.Severity} annotation
 *
 * @return {@link ru.yandex.qatools.allure.model.SeverityLevel} or null if
 * annotation doesn't present
 */
public SeverityLevel getSeverity() {
    Severity severity = getAnnotation(Severity.class);
    return severity == null ? null : severity.value();
}