Java Code Examples for io.qameta.allure.model.TestResult#setParameters()

The following examples show how to use io.qameta.allure.model.TestResult#setParameters() . 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: AllureCucumber2Jvm.java    From allure-java with Apache License 2.0 4 votes vote down vote up
private void handleTestCaseStarted(final TestCaseStarted event) {
    currentTestCase = event.testCase;
    currentFeatureFile = currentTestCase.getUri();
    currentFeature = cucumberSourceUtils.getFeature(currentFeatureFile);
    currentContainer = UUID.randomUUID().toString();
    forbidTestCaseStatusChange = false;


    final Deque<PickleTag> tags = new LinkedList<>(currentTestCase.getTags());

    final LabelBuilder labelBuilder = new LabelBuilder(currentFeature, currentTestCase, tags);

    final String name = currentTestCase.getName();
    final String featureName = currentFeature.getName();

    final TestResult result = new TestResult()
            .setUuid(getTestCaseUuid(currentTestCase))
            .setHistoryId(getHistoryId(currentTestCase))
            .setFullName(featureName + ": " + name)
            .setName(name)
            .setLabels(labelBuilder.getScenarioLabels())
            .setLinks(labelBuilder.getScenarioLinks());

    final ScenarioDefinition scenarioDefinition =
            cucumberSourceUtils.getScenarioDefinition(currentFeatureFile, currentTestCase.getLine());
    if (scenarioDefinition instanceof ScenarioOutline) {
        result.setParameters(
                getExamplesAsParameters((ScenarioOutline) scenarioDefinition)
        );
    }

    if (currentFeature.getDescription() != null && !currentFeature.getDescription().isEmpty()) {
        result.setDescription(currentFeature.getDescription());
    }

    final TestResultContainer resultContainer = new TestResultContainer()
            .setName(String.format("%s: %s", scenarioDefinition.getKeyword(), scenarioDefinition.getName()))
            .setUuid(getTestContainerUuid())
            .setChildren(Collections.singletonList(getTestCaseUuid(currentTestCase)));

    lifecycle.scheduleTestCase(result);
    lifecycle.startTestContainer(getTestContainerUuid(), resultContainer);
    lifecycle.startTestCase(getTestCaseUuid(currentTestCase));
}
 
Example 2
Source File: AllureCucumber4Jvm.java    From allure-java with Apache License 2.0 4 votes vote down vote up
private void handleTestCaseStarted(final TestCaseStarted event) {
    currentFeatureFile.set(event.testCase.getUri());
    currentFeature.set(testSources.getFeature(currentFeatureFile.get()));
    currentTestCase.set(event.testCase);
    currentContainer.set(UUID.randomUUID().toString());
    forbidTestCaseStatusChange.set(false);

    final Deque<PickleTag> tags = new LinkedList<>(currentTestCase.get().getTags());

    final Feature feature = currentFeature.get();
    final LabelBuilder labelBuilder = new LabelBuilder(feature, currentTestCase.get(), tags);

    final String name = currentTestCase.get().getName();
    final String featureName = feature.getName();

    final TestResult result = new TestResult()
            .setUuid(getTestCaseUuid(currentTestCase.get()))
            .setHistoryId(getHistoryId(currentTestCase.get()))
            .setFullName(featureName + ": " + name)
            .setName(name)
            .setLabels(labelBuilder.getScenarioLabels())
            .setLinks(labelBuilder.getScenarioLinks());

    final ScenarioDefinition scenarioDefinition =
            testSources.getScenarioDefinition(currentFeatureFile.get(), currentTestCase.get().getLine());
    if (scenarioDefinition instanceof ScenarioOutline) {
        result.setParameters(
                getExamplesAsParameters((ScenarioOutline) scenarioDefinition, currentTestCase.get())
        );
    }

    final String description = Stream.of(feature.getDescription(), scenarioDefinition.getDescription())
            .filter(Objects::nonNull)
            .filter(s -> !s.isEmpty())
            .collect(Collectors.joining("\n"));

    if (!description.isEmpty()) {
        result.setDescription(description);
    }

    final TestResultContainer resultContainer = new TestResultContainer()
            .setName(String.format("%s: %s", scenarioDefinition.getKeyword(), scenarioDefinition.getName()))
            .setUuid(getTestContainerUuid())
            .setChildren(Collections.singletonList(getTestCaseUuid(currentTestCase.get())));

    lifecycle.scheduleTestCase(result);
    lifecycle.startTestContainer(getTestContainerUuid(), resultContainer);
    lifecycle.startTestCase(getTestCaseUuid(currentTestCase.get()));
}
 
Example 3
Source File: AllureCucumber3Jvm.java    From allure-java with Apache License 2.0 4 votes vote down vote up
private void handleTestCaseStarted(final TestCaseStarted event) {
    currentTestCase = event.testCase;
    currentFeatureFile = currentTestCase.getUri();
    currentFeature = cucumberSourceUtils.getFeature(currentFeatureFile);
    currentContainer = UUID.randomUUID().toString();
    forbidTestCaseStatusChange = false;


    final Deque<PickleTag> tags = new LinkedList<>(currentTestCase.getTags());

    final LabelBuilder labelBuilder = new LabelBuilder(currentFeature, currentTestCase, tags);

    final String name = currentTestCase.getName();
    final String featureName = currentFeature.getName();

    final TestResult result = new TestResult()
            .setUuid(getTestCaseUuid(currentTestCase))
            .setHistoryId(getHistoryId(currentTestCase))
            .setFullName(featureName + ": " + name)
            .setName(name)
            .setLabels(labelBuilder.getScenarioLabels())
            .setLinks(labelBuilder.getScenarioLinks());

    final ScenarioDefinition scenarioDefinition =
            cucumberSourceUtils.getScenarioDefinition(currentFeatureFile, currentTestCase.getLine());
    if (scenarioDefinition instanceof ScenarioOutline) {
        result.setParameters(
                getExamplesAsParameters((ScenarioOutline) scenarioDefinition)
        );
    }

    if (currentFeature.getDescription() != null && !currentFeature.getDescription().isEmpty()) {
        result.setDescription(currentFeature.getDescription());
    }

    final TestResultContainer resultContainer = new TestResultContainer()
            .setName(String.format("%s: %s", scenarioDefinition.getKeyword(), scenarioDefinition.getName()))
            .setUuid(getTestContainerUuid())
            .setChildren(Collections.singletonList(getTestCaseUuid(currentTestCase)));

    lifecycle.scheduleTestCase(result);
    lifecycle.startTestContainer(getTestContainerUuid(), resultContainer);
    lifecycle.startTestCase(getTestCaseUuid(currentTestCase));
}