ru.yandex.qatools.allure.events.TestSuiteStartedEvent Java Examples

The following examples show how to use ru.yandex.qatools.allure.events.TestSuiteStartedEvent. 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: AnnotationManager.java    From allure1 with Apache License 2.0 6 votes vote down vote up
/**
 * Sets into specified {@link ru.yandex.qatools.allure.events.TestSuiteStartedEvent}
 * information from Allure annotations.
 *
 * @param event to change
 */
public void update(TestSuiteStartedEvent event) {
    if (isTitleAnnotationPresent()) {
        event.setTitle(getTitle());
    }

    if (isDescriptionAnnotationPresent()) {
        event.setDescription(getDescription());
    }

    if (isIssueAnnotationPresent()) {
        event.getLabels().add(createIssueLabel(getIssueKey()));
    }

    if (isIssuesAnnotationPresent()) {
        for (String issueKey : getIssueKeys()) {
            event.getLabels().add(createIssueLabel(issueKey));
        }
    }

    event.getLabels().addAll(getStoryLabels());
    event.getLabels().addAll(getFeatureLabels());
}
 
Example #2
Source File: AnnotationManagerTest.java    From allure1 with Apache License 2.0 6 votes vote down vote up
@Test
public void testUpdateTestSuiteStartedEvent() throws Exception {
    TestSuiteStartedEvent event = new TestSuiteStartedEvent("some.uid", "some.name");
    annotationManager.update(event);

    assertThat(event.getTitle(), equalTo("some.title"));

    Description description = annotationManager.getDescription();
    assertThat(description.getValue(), is("some.description"));
    assertThat(description.getType(), is(DescriptionType.TEXT));

    assertThat(event.getLabels(), not(hasItems(
            createSeverityLabel(SeverityLevel.BLOCKER)
    )));
    assertThat(event.getLabels(), hasItems(
            createStoryLabel("some.story"), 
            createFeatureLabel("some.feature"),
            createIssueLabel("some.simple.issue"),
            createIssueLabel("some.nested.issue.1"),
            createIssueLabel("some.nested.issue.2")
    ));   
}
 
Example #3
Source File: AllureTestListener.java    From allure1 with Apache License 2.0 6 votes vote down vote up
@Override
public void onConfigurationSkip(ITestResult iTestResult) {
    if (isSuppressConfigEvent(iTestResult)) {
        return;
    }
    String suiteUid = getSuiteUid(iTestResult.getTestContext());
    if (isAfterSuiteConfigMethod(iTestResult)) {
        String suiteTitle = getCurrentSuiteTitle(iTestResult.getTestContext());
        getLifecycle().fire(new TestSuiteStartedEvent(suiteUid, suiteTitle).withTitle(suiteTitle));
    }
    createConfigEvent(iTestResult);
    fireTestCaseCancel(iTestResult);
    fireFinishTest();
    if (isAfterSuiteConfigMethod(iTestResult)) {
        getLifecycle().fire(new TestSuiteFinishedEvent(suiteUid));
    }
}
 
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: AllureLifecycleTest.java    From allure1 with Apache License 2.0 5 votes vote down vote up
@Test
public void supportForConcurrentUseOfChildThreadsTestCases() throws Exception {
    final int threads = 20;
    final int testCases = 1000;

    final Allure lifecycle = Allure.LIFECYCLE;

    String suiteUid = UUID.randomUUID().toString();
    fireTestSuiteStart(suiteUid);
    fireTestCaseStart(suiteUid);

    ExecutorService service = Executors.newFixedThreadPool(threads);

    final List<Callable<Object>> tasks = new ArrayList<>();

    final String uid = UUID.randomUUID().toString();
    lifecycle.fire(new TestSuiteStartedEvent(uid, uid));
    for (int i = 0; i < threads; i++) {
        tasks.add(new Callable<Object>() {
            @Override
            public Object call() throws Exception {
                for (int i = 0; i < testCases; i++) {
                    lifecycle.fire(new TestCaseStartedEvent(uid, "test-case"));
                    lifecycle.fire(new StepFinishedEvent());
                }
                return "";
            }
        });
    }

    List<Future<Object>> futures = service.invokeAll(tasks);
    for (Future<Object> future : futures) {
        future.get();
    }

    assertThat(lifecycle.getTestSuiteStorage().get(uid).getTestCases(), hasSize(threads * testCases));
}
 
Example #6
Source File: AllureLifecycleTest.java    From allure1 with Apache License 2.0 5 votes vote down vote up
public TestSuiteResult fireTestSuiteStart(String uid) {
    Allure.LIFECYCLE.fire(new TestSuiteStartedEvent(uid, "some.suite.name"));
    TestSuiteResult testSuite = Allure.LIFECYCLE.getTestSuiteStorage().get(uid);
    assertNotNull(testSuite);
    assertThat(testSuite.getName(), is("some.suite.name"));
    assertThat(testSuite.getTestCases(), hasSize(0));
    return testSuite;
}
 
Example #7
Source File: AllureTestListener.java    From allure1 with Apache License 2.0 5 votes vote down vote up
@Override
public void onStart(ITestContext iTestContext) {
    getLifecycle().fire(new TestSuiteStartedEvent(
            getSuiteUid(iTestContext), getCurrentSuiteTitle(iTestContext)
    ).withTitle(
            getCurrentSuiteTitle(iTestContext)
    ).withLabels(
            AllureModelUtils.createTestFrameworkLabel("TestNG")
    ));
    addPendingMethods(iTestContext);
}
 
Example #8
Source File: AllureTestListener.java    From allure1 with Apache License 2.0 5 votes vote down vote up
@Override
public void onConfigurationFailure(ITestResult iTestResult) {
    if (isSuppressConfigEvent(iTestResult)) {
        return;
    }
    String suiteUid = getSuiteUid(iTestResult.getTestContext());
    if (isAfterSuiteConfigMethod(iTestResult)) {
        String suiteTitle = getCurrentSuiteTitle(iTestResult.getTestContext());
        getLifecycle().fire(new TestSuiteStartedEvent(suiteUid, suiteTitle).withTitle(suiteTitle));
    }
    Throwable throwable = iTestResult.getThrowable();
    createConfigEvent(iTestResult);
    getLifecycle().fire(new TestCaseFailureEvent().withThrowable(throwable));
    fireFinishTest();
    if (isAfterSuiteConfigMethod(iTestResult)) {
        getLifecycle().fire(new TestSuiteFinishedEvent(suiteUid));
    }
}
 
Example #9
Source File: ListenersNotifierTest.java    From allure1 with Apache License 2.0 4 votes vote down vote up
@Test
public void testsuiteFinishedEventTest() throws Exception {
    allure.fire(new TestSuiteStartedEvent("uid", "name"));
    allure.fire(new TestSuiteFinishedEvent("uid"));
    assertThat(listener.get(SimpleListener.EventType.TESTSUITE_FINISHED_EVENT), is(1));
}
 
Example #10
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 #11
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);
}