ru.yandex.qatools.allure.utils.AnnotationManager Java Examples

The following examples show how to use ru.yandex.qatools.allure.utils.AnnotationManager. 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: AllureRunListener.java    From allure-cucumberjvm with Apache License 2.0 6 votes vote down vote up
@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);
    }
}
 
Example #2
Source File: AllureTestListener.java    From allure1 with Apache License 2.0 6 votes vote down vote up
private void addPendingMethods(ITestContext iTestContext) {
    for (ITestNGMethod method : iTestContext.getExcludedMethods()) {
        if (method.isTest() && !method.getEnabled() && isInActiveGroup(method, iTestContext)) {
            Description description = new Description().withValue(method.getDescription());
            String suiteUid = getSuiteUid(iTestContext);
            TestCaseStartedEvent event = new TestCaseStartedEvent(suiteUid, method.getMethodName());
            if (description.getValue() != null) {
                event.setDescription(description);
            }
            Annotation[] annotations = method.getConstructorOrMethod().getMethod().getAnnotations();
            AnnotationManager am = new AnnotationManager(annotations);
            am.setDefaults(method.getInstance().getClass().getAnnotations());
            am.update(event);
            getLifecycle().fire(event);
            getLifecycle().fire(new TestCasePendingEvent());
            fireFinishTest();
        }
    }
}
 
Example #3
Source File: AllureMarathonRunListener.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
public void startFakeTestCase(Description description) {
    String uid = getSuiteUid(description);

    String name = description.isTest() ? getTestName() : getSuiteName(description);
    TestCaseStartedEvent event = new TestCaseStartedEvent(uid, name);
    AnnotationManager am = new AnnotationManager(description.getAnnotations());
    am.update(event);

    fireClearStepStorage();
    getLifecycle().fire(event);
}
 
Example #4
Source File: AllureRunListener.java    From allure-cucumberjvm with Apache License 2.0 5 votes vote down vote up
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);
    }
 
Example #5
Source File: AllureRunListener.java    From allure-cucumberjvm with Apache License 2.0 5 votes vote down vote up
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);
}
 
Example #6
Source File: AllureRunListener.java    From allure1 with Apache License 2.0 5 votes vote down vote up
@Override
public void testStarted(Description description) {
    TestCaseStartedEvent event = new TestCaseStartedEvent(getSuiteUid(description), description.getMethodName());
    AnnotationManager am = new AnnotationManager(description.getAnnotations());

    am.update(event);

    fireClearStepStorage();
    getLifecycle().fire(event);
}
 
Example #7
Source File: AllureRunListener.java    From allure1 with Apache License 2.0 5 votes vote down vote up
public void startFakeTestCase(Description description) {
    String uid = getSuiteUid(description);

    String name = description.isTest() ? description.getMethodName() : description.getClassName();
    TestCaseStartedEvent event = new TestCaseStartedEvent(uid, name);
    AnnotationManager am = new AnnotationManager(description.getAnnotations());
    am.update(event);

    fireClearStepStorage();
    getLifecycle().fire(event);
}
 
Example #8
Source File: AllureTestListener.java    From allure1 with Apache License 2.0 5 votes vote down vote up
@Override
public void onTestStart(ITestResult iTestResult) {
    ITestNGMethod method = iTestResult.getMethod();
    String testSuiteLabel = iTestResult.getTestContext().getSuite().getName();
    String testGroupLabel = iTestResult.getTestContext().getCurrentXmlTest().getName();
    String testClassLabel = iTestResult.getTestClass().getName();
    String testMethodLabel = method.getMethodName();
    String suitePrefix = getCurrentSuitePrefix(iTestResult);
    String testName = getName(iTestResult);
    startedTestNames.add(testName);
    testName = testName.replace(suitePrefix, "");

    String invoc = getMethodInvocationsAndSuccessPercentage(iTestResult);
    Description description = new Description().withValue(method.getDescription());
    String suiteUid = getSuiteUid(iTestResult.getTestContext());
    TestCaseStartedEvent event = new TestCaseStartedEvent(suiteUid, testName + invoc).withLabels(
            AllureModelUtils.createTestSuiteLabel(testSuiteLabel),
            AllureModelUtils.createTestGroupLabel(testGroupLabel),
            AllureModelUtils.createTestClassLabel(testClassLabel),
            AllureModelUtils.createTestMethodLabel(testMethodLabel));
    if (description.getValue() != null) {
        event.setDescription(description);
    }
    AnnotationManager am = new AnnotationManager(getMethodAnnotations(iTestResult));
    am.setDefaults(getClassAnnotations(iTestResult));
    am.update(event);

    getLifecycle().fire(event);

    if (AllureConfig.newInstance().areTestNgParametersEnabled()) {
        fireAddParameterEvents(iTestResult);
    }
}
 
Example #9
Source File: AllureTestListener.java    From allure1 with Apache License 2.0 5 votes vote down vote up
private void createConfigEvent(ITestResult iTestResult) {
    String description = iTestResult.getMethod().getDescription();
    if (description == null || description.isEmpty()) {
        description = getConfigMethodType(iTestResult).getName();
    }
    String suiteUid = getSuiteUid(iTestResult.getTestContext());
    TestCaseStartedEvent event = new TestCaseStartedEvent(suiteUid, iTestResult.getName());
    event.setDescription(new Description().withValue(description));
    AnnotationManager am = new AnnotationManager(getMethodAnnotations(iTestResult));
    am.setDefaults(getClassAnnotations(iTestResult));
    am.update(event);
    getLifecycle().fire(event);
}
 
Example #10
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 #11
Source File: AllureMarathonRunListener.java    From marathonv5 with Apache License 2.0 3 votes vote down vote up
public void testSuiteStarted(Description description) {
    String uid = generateSuiteUid(getSuiteName(description));

    TestSuiteStartedEvent event = new TestSuiteStartedEvent(uid, getSuiteName(description));
    AnnotationManager am = new AnnotationManager(description.getAnnotations());

    am.update(event);

    event.withLabels(AllureModelUtils.createTestFrameworkLabel("Marathon"));

    getLifecycle().fire(event);
}
 
Example #12
Source File: AllureRunListener.java    From allure1 with Apache License 2.0 3 votes vote down vote up
public void testSuiteStarted(Description description) {
    String uid = generateSuiteUid(description.getClassName());

    TestSuiteStartedEvent event = new TestSuiteStartedEvent(uid, description.getClassName());
    AnnotationManager am = new AnnotationManager(description.getAnnotations());

    am.update(event);

    event.withLabels(AllureModelUtils.createTestFrameworkLabel("JUnit"));

    getLifecycle().fire(event);
}