io.qameta.allure.entity.Status Java Examples

The following examples show how to use io.qameta.allure.entity.Status. 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: JunitXmlPluginTest.java    From allure2 with Apache License 2.0 6 votes vote down vote up
@Test
void shouldReadSkippedStatus() throws Exception {
    process(
            "junitdata/TEST-status-attribute.xml", "TEST-test.SampleTest.xml"
    );

    final ArgumentCaptor<TestResult> captor = ArgumentCaptor.forClass(TestResult.class);
    verify(visitor, times(3)).visitTestResult(captor.capture());

    List<TestResult> skipped = filterByStatus(captor.getAllValues(), Status.SKIPPED);

    assertThat(skipped)
            .describedAs("Should parse skipped elements and status attribute")
            .hasSize(2);

}
 
Example #2
Source File: CucumberJsonResultsReader.java    From allure2 with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("PMD.UnnecessaryFullyQualifiedName")
private Status getStatus(final net.masterthought.cucumber.json.support.Status status) {
    if (status.isPassed()) {
        return Status.PASSED;
    }
    if (status == FAILED) {
        return Status.FAILED;
    }
    if (status == PENDING) {
        return Status.SKIPPED;
    }
    if (status == SKIPPED) {
        return Status.SKIPPED;
    }
    return Status.UNKNOWN;
}
 
Example #3
Source File: BehaviorsPluginTest.java    From allure2 with Apache License 2.0 6 votes vote down vote up
@Test
void shouldGroupByEpic() {
    final Set<TestResult> testResults = new HashSet<>();
    testResults.add(new TestResult()
            .setStatus(Status.PASSED)
            .setLabels(asList(EPIC.label("e1"), FEATURE.label("f1"), STORY.label("s1"))));
    testResults.add(new TestResult()
            .setStatus(Status.FAILED)
            .setLabels(asList(EPIC.label("e2"), FEATURE.label("f2"), STORY.label("s2"))));

    LaunchResults results = new DefaultLaunchResults(testResults, Collections.emptyMap(), Collections.emptyMap());
    TreeWidgetData behaviorsData = new BehaviorsPlugin.WidgetAggregator()
            .getData(Collections.singletonList(results));

    assertThat(behaviorsData.getItems())
            .extracting("name")
            .containsExactlyInAnyOrder("e1", "e2");
}
 
Example #4
Source File: HistoryTrendPluginTest.java    From allure2 with Apache License 2.0 6 votes vote down vote up
@Test
void shouldProcessNullBuildOrder() {
    final List<HistoryTrendItem> history = randomHistoryTrendItems();
    final Map<String, Object> extra = new HashMap<>();
    extra.put(HISTORY_TREND_BLOCK_NAME, history);
    extra.put(EXECUTORS_BLOCK_NAME, new ExecutorInfo().setBuildOrder(null));

    final List<LaunchResults> launchResults = Arrays.asList(
            createLaunchResults(extra,
                    randomTestResult().setStatus(Status.PASSED),
                    randomTestResult().setStatus(Status.FAILED),
                    randomTestResult().setStatus(Status.FAILED)
            ),
            createLaunchResults(extra,
                    randomTestResult().setStatus(Status.PASSED),
                    randomTestResult().setStatus(Status.FAILED),
                    randomTestResult().setStatus(Status.FAILED)
            )
    );
    final List<HistoryTrendItem> data = HistoryTrendPlugin.getData(launchResults);

    assertThat(data)
            .hasSize(1 + 2 * history.size());
}
 
Example #5
Source File: CategoriesPluginTest.java    From allure2 with Apache License 2.0 6 votes vote down vote up
@Test
void shouldDefaultCategoriesToResults() {
    final TestResult first = new TestResult()
            .setName("first")
            .setStatus(Status.FAILED)
            .setStatusMessage("A");
    final TestResult second = new TestResult()
            .setName("second")
            .setStatus(Status.BROKEN)
            .setStatusMessage("B");

    CategoriesPlugin.addCategoriesForResults(createSingleLaunchResults(first, second));

    assertThat(first.getExtraBlock(CATEGORIES, new ArrayList<Category>()))
            .hasSize(1)
            .extracting(Category::getName)
            .containsExactlyInAnyOrder(FAILED_TESTS.getName());

    assertThat(second.getExtraBlock(CATEGORIES, new ArrayList<Category>()))
            .hasSize(1)
            .extracting(Category::getName)
            .containsExactlyInAnyOrder(BROKEN_TESTS.getName());

}
 
Example #6
Source File: RetryPluginTest.java    From allure2 with Apache License 2.0 6 votes vote down vote up
@Test
void shouldNotMarkLatestAsFlakyIfRetriesArePassed() {
    String historyId = UUID.randomUUID().toString();
    List<LaunchResults> launchResultsList = createSingleLaunchResults(
            createTestResult(FIRST_RESULT, historyId, 1L, 9L).setStatus(Status.PASSED),
            createTestResult(SECOND_RESULT, historyId, 11L, 19L).setStatus(Status.PASSED)
    );
    retryPlugin.aggregate(null, launchResultsList, null);
    Set<TestResult> results = launchResultsList.get(0).getAllResults();

    assertThat(results)
            .filteredOn(TestResult::isHidden)
            .extracting(TestResult::getName)
            .containsExactlyInAnyOrder(FIRST_RESULT);

    assertThat(results)
            .filteredOn(result -> !result.isHidden())
            .extracting(TestResult::getName, TestResult::isFlaky)
            .containsExactlyInAnyOrder(tuple(SECOND_RESULT, false));
}
 
Example #7
Source File: JunitXmlPlugin.java    From allure2 with Apache License 2.0 6 votes vote down vote up
private Status getStatus(final XmlElement testCaseElement) {
    if (testCaseElement.contains(FAILURE_ELEMENT_NAME)) {
        return Status.FAILED;
    }
    if (testCaseElement.contains(ERROR_ELEMENT_NAME)) {
        return Status.BROKEN;
    }
    if (testCaseElement.contains(SKIPPED_ELEMENT_NAME)) {
        return Status.SKIPPED;
    }

    if ((testCaseElement.containsAttribute(STATUS_ATTRIBUTE_NAME))
            && (testCaseElement.getAttribute(STATUS_ATTRIBUTE_NAME).equals(SKIPPED_ATTRIBUTE_VALUE))) {
        return Status.SKIPPED;
    }

    return Status.PASSED;
}
 
Example #8
Source File: RetryPlugin.java    From allure2 with Apache License 2.0 6 votes vote down vote up
private Consumer<TestResult> addRetries(final List<TestResult> results) {
    return latest -> {
        final List<RetryItem> retries = results.stream()
                .sorted(comparingByTime())
                .filter(result -> !latest.equals(result))
                .map(this::prepareRetry)
                .map(this::createRetryItem)
                .collect(Collectors.toList());
        latest.addExtraBlock(RETRY_BLOCK_NAME, retries);
        final Set<Status> statuses = retries.stream()
                .map(RetryItem::getStatus)
                .distinct()
                .collect(Collectors.toSet());

        statuses.remove(Status.PASSED);
        statuses.remove(Status.SKIPPED);

        latest.setFlaky(!statuses.isEmpty());
    };
}
 
Example #9
Source File: Allure1Plugin.java    From allure2 with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("ReturnCount")
public static Status convert(final ru.yandex.qatools.allure.model.Status status) {
    if (Objects.isNull(status)) {
        return Status.UNKNOWN;
    }
    switch (status) {
        case FAILED:
            return FAILED;
        case BROKEN:
            return BROKEN;
        case PASSED:
            return PASSED;
        case CANCELED:
        case SKIPPED:
        case PENDING:
            return SKIPPED;
        default:
            return Status.UNKNOWN;
    }
}
 
Example #10
Source File: Allure1Plugin.java    From allure2 with Apache License 2.0 6 votes vote down vote up
private Step convert(final Path source,
                     final ResultsVisitor visitor,
                     final ru.yandex.qatools.allure.model.Step s,
                     final Status testStatus,
                     final String message,
                     final String trace) {
    final Status status = convert(s.getStatus());
    final Step current = new Step()
            .setName(s.getTitle() == null ? s.getName() : s.getTitle())
            .setTime(new Time()
                    .setStart(s.getStart())
                    .setStop(s.getStop())
                    .setDuration(s.getStop() - s.getStart()))
            .setStatus(status)
            .setSteps(convert(s.getSteps(), step -> convert(source, visitor, step, testStatus, message, trace)))
            .setAttachments(convert(s.getAttachments(), attach -> convert(source, visitor, attach)));
    //Copy test status details to each step set the same status
    if (Objects.equals(status, testStatus)) {
        current.setStatusMessage(message);
        current.setStatusMessage(trace);
    }
    return current;
}
 
Example #11
Source File: RetryPluginTest.java    From allure2 with Apache License 2.0 6 votes vote down vote up
@Test
void shouldNotMarkLatestAsFlakyIfRetriesSkipped() {
    String historyId = UUID.randomUUID().toString();
    List<LaunchResults> launchResultsList = createSingleLaunchResults(
            createTestResult(FIRST_RESULT, historyId, 1L, 9L).setStatus(Status.SKIPPED),
            createTestResult(SECOND_RESULT, historyId, 11L, 19L).setStatus(Status.PASSED),
            createTestResult(LAST_RESULT, historyId, 12L, 20L).setHidden(true).setStatus(Status.PASSED)
    );
    retryPlugin.aggregate(null, launchResultsList, null);
    Set<TestResult> results = launchResultsList.get(0).getAllResults();

    assertThat(results)
            .filteredOn(TestResult::isHidden)
            .extracting(TestResult::getName)
            .containsExactlyInAnyOrder(FIRST_RESULT, LAST_RESULT);

    assertThat(results)
            .filteredOn(result -> !result.isHidden())
            .extracting(TestResult::getName, TestResult::isFlaky)
            .containsExactlyInAnyOrder(tuple(SECOND_RESULT, false));
}
 
Example #12
Source File: XunitXmlPluginTest.java    From allure2 with Apache License 2.0 6 votes vote down vote up
@Test
void shouldCreateTest() throws Exception {
    process(
            "xunitdata/passed-test.xml",
            "passed-test.xml"
    );

    final ArgumentCaptor<TestResult> captor = ArgumentCaptor.forClass(TestResult.class);
    verify(visitor, times(1)).visitTestResult(captor.capture());

    assertThat(captor.getAllValues())
            .hasSize(1)
            .extracting(TestResult::getName, TestResult::getHistoryId, TestResult::getStatus)
            .containsExactlyInAnyOrder(
                    Tuple.tuple("passedTest", "Some test", Status.PASSED)
            );
}
 
Example #13
Source File: CsvExportBehavior.java    From allure2 with Apache License 2.0 6 votes vote down vote up
public void addTestResult(final TestResult result) {
    if (Status.FAILED.equals(result.getStatus())) {
        this.failed++;
    }
    if (Status.BROKEN.equals(result.getStatus())) {
        this.broken++;
    }
    if (Status.PASSED.equals(result.getStatus())) {
        this.passed++;
    }
    if (Status.SKIPPED.equals(result.getStatus())) {
        this.skipped++;
    }
    if (Status.UNKNOWN.equals(result.getStatus())) {
        this.unknown++;
    }
}
 
Example #14
Source File: CategoriesPlugin.java    From allure2 with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("PMD.DefaultPackage")
/* default */ static void addCategoriesForResults(final List<LaunchResults> launchesResults) {
    launchesResults.forEach(launch -> {
        final List<Category> categories = launch.getExtra(CATEGORIES, Collections::emptyList);
        launch.getResults().forEach(result -> {
            final List<Category> resultCategories = result.getExtraBlock(CATEGORIES, new ArrayList<>());
            categories.forEach(category -> {
                if (matches(result, category)) {
                    resultCategories.add(category);
                }
            });
            if (resultCategories.isEmpty() && Status.FAILED.equals(result.getStatus())) {
                result.getExtraBlock(CATEGORIES, new ArrayList<Category>()).add(FAILED_TESTS);
            }
            if (resultCategories.isEmpty() && Status.BROKEN.equals(result.getStatus())) {
                result.getExtraBlock(CATEGORIES, new ArrayList<Category>()).add(BROKEN_TESTS);
            }
        });
    });
}
 
Example #15
Source File: TrxPluginTest.java    From allure2 with Apache License 2.0 6 votes vote down vote up
@Test
void shouldParseResults() throws Exception {
    process(
            "trxdata/sample.trx",
            "sample.trx"
    );

    final ArgumentCaptor<TestResult> captor = ArgumentCaptor.forClass(TestResult.class);
    verify(visitor, times(4)).visitTestResult(captor.capture());

    assertThat(captor.getAllValues())
            .hasSize(4)
            .extracting(TestResult::getName, TestResult::getStatus, TestResult::getDescription)
            .containsExactlyInAnyOrder(
                    tuple("AddingSeveralNumbers_40", Status.PASSED, "Adding several numbers"),
                    tuple("AddingSeveralNumbers_60", Status.PASSED, "Adding several numbers"),
                    tuple("AddTwoNumbers", Status.PASSED, "Add two numbers"),
                    tuple("FailToAddTwoNumbers", Status.FAILED, "Fail to add two numbers")
            );

    assertThat(captor.getAllValues())
            .extracting(result -> result.findOneLabel(LabelName.RESULT_FORMAT))
            .extracting(Optional::get)
            .containsOnly(TrxPlugin.TRX_RESULTS_FORMAT);

}
 
Example #16
Source File: TrxPluginTest.java    From allure2 with Apache License 2.0 6 votes vote down vote up
@Test
void shouldParseStdOutOnFail() throws Exception {
    process(
            "trxdata/sample.trx",
            "sample.trx"
    );

    final ArgumentCaptor<TestResult> captor = ArgumentCaptor.forClass(TestResult.class);
    verify(visitor, times(4)).visitTestResult(captor.capture());

    assertThat(captor.getAllValues())
            .filteredOn(result -> result.getStatus() == Status.FAILED)
            .filteredOn(result -> result.getTestStage().getSteps().size() == 10)
            .filteredOn(result -> result.getTestStage().getSteps().get(1).getName().contains("Given I have entered 50 into the calculator"))
            .filteredOn(result -> result.getTestStage().getSteps().get(3).getName().contains("And I have entered -1 into the calculator"))
            .hasSize(1);
}
 
Example #17
Source File: HistoryPluginTest.java    From allure2 with Apache License 2.0 6 votes vote down vote up
@Test
void shouldHasNewFailedMark() {
    String historyId = UUID.randomUUID().toString();
    final Map<String, Object> extra = new HashMap<>();
    final Map<String, HistoryData> historyDataMap = createHistoryDataMap(
            historyId,
            createHistoryItem(PASSED, 1, 2)
    );

    extra.put(HISTORY_BLOCK_NAME, historyDataMap);
    TestResult testResult = createTestResult(Status.FAILED, historyId, 100, 101);
    new HistoryPlugin().getData(singletonList(
            createLaunchResults(extra, testResult)
    ));
    assertThat(testResult.isNewFailed()).isTrue();
    assertThat(testResult.isFlaky()).isFalse();
}
 
Example #18
Source File: HistoryPluginTest.java    From allure2 with Apache License 2.0 6 votes vote down vote up
@Test
void shouldHasFlakyMark() {
    String historyId = UUID.randomUUID().toString();
    final Map<String, Object> extra = new HashMap<>();
    final Map<String, HistoryData> historyDataMap = createHistoryDataMap(
            historyId,
            createHistoryItem(PASSED, 3, 4),
            createHistoryItem(Status.FAILED, 1, 2)
    );

    extra.put(HISTORY_BLOCK_NAME, historyDataMap);
    TestResult testResult = createTestResult(Status.FAILED, historyId, 100, 101);
    new HistoryPlugin().getData(singletonList(
            createLaunchResults(extra, testResult)
    ));
    assertThat(testResult.isNewFailed()).isTrue();
    assertThat(testResult.isFlaky()).isTrue();
}
 
Example #19
Source File: HistoryTrendPluginTest.java    From allure2 with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
@Test
void shouldGetData() {
    final List<HistoryTrendItem> history = randomHistoryTrendItems();
    final List<HistoryTrendItem> data = HistoryTrendPlugin.getData(createSingleLaunchResults(
            singletonMap(HISTORY_TREND_BLOCK_NAME, history),
            randomTestResult().setStatus(Status.PASSED),
            randomTestResult().setStatus(Status.FAILED),
            randomTestResult().setStatus(Status.FAILED)
    ));

    assertThat(data)
            .hasSize(1 + history.size())
            .extracting(HistoryTrendItem::getStatistic)
            .extracting(Statistic::getTotal, Statistic::getFailed, Statistic::getPassed)
            .first()
            .isEqualTo(Tuple.tuple(3L, 2L, 1L));

    final List<HistoryTrendItem> next = data.subList(1, data.size());

    assertThat(next)
            .containsExactlyElementsOf(history);

}
 
Example #20
Source File: JunitXmlPluginTest.java    From allure2 with Apache License 2.0 5 votes vote down vote up
@Test
void shouldReadJunitResults() throws Exception {
    process(
            "junitdata/TEST-org.allurefw.report.junit.JunitTestResultsTest.xml",
            "TEST-org.allurefw.report.junit.JunitTestResultsTest.xml"
    );

    final ArgumentCaptor<TestResult> captor = ArgumentCaptor.forClass(TestResult.class);
    verify(visitor, times(5)).visitTestResult(captor.capture());


    assertThat(captor.getAllValues())
            .hasSize(5);

    List<TestResult> failed = filterByStatus(captor.getAllValues(), Status.FAILED);
    List<TestResult> skipped = filterByStatus(captor.getAllValues(), Status.SKIPPED);
    List<TestResult> passed = filterByStatus(captor.getAllValues(), Status.PASSED);

    assertThat(failed)
            .describedAs("Should parse failed status")
            .hasSize(1);

    assertThat(skipped)
            .describedAs("Should parse skipped status")
            .hasSize(1);

    assertThat(passed)
            .describedAs("Should parse passed status")
            .hasSize(3);
}
 
Example #21
Source File: XcTestPlugin.java    From allure2 with Apache License 2.0 5 votes vote down vote up
private void parseTest(final String suiteName, final Object test,
                       final Path directory, final ResultsVisitor visitor) {
    final Map<String, Object> props = asMap(test);
    final TestResult result = ResultsUtils.getTestResult(props);
    result.addLabelIfNotExists(RESULT_FORMAT, XCTEST_RESULTS_FORMAT);
    result.addLabelIfNotExists(SUITE, suiteName);

    asList(props.getOrDefault(ACTIVITY_SUMMARIES, emptyList()))
            .forEach(activity -> parseStep(directory, result, activity, visitor));
    final Optional<Step> lastFailedStep = result.getTestStage().getSteps().stream()
            .filter(s -> !s.getStatus().equals(Status.PASSED)).sorted((a, b) -> -1).findFirst();
    lastFailedStep.map(Step::getStatusMessage).ifPresent(result::setStatusMessage);
    lastFailedStep.map(Step::getStatusTrace).ifPresent(result::setStatusTrace);
    visitor.visitTestResult(result);
}
 
Example #22
Source File: JiraExportUtilitiesTest.java    From allure2 with Apache License 2.0 5 votes vote down vote up
@Test
public void emptyTestResultsShouldBeIgnoredWhenConvertingToLaunchStatisticExport() {
    final long resultCount = 1;
    final LaunchResults launchResults = mock(LaunchResults.class);
    final TestResult passed = createTestResult(Status.PASSED);
    final TestResult failed = createTestResult(Status.FAILED);
    final TestResult unknown = createTestResult(Status.UNKNOWN);

    final Set<TestResult> results = new HashSet<>(Arrays.asList(passed, failed, unknown));
    when(launchResults.getAllResults()).thenReturn(results);

    final Statistic statistic = JiraExportUtils.getStatistic(Arrays.asList(launchResults));
    final List<LaunchStatisticExport> launchStatisticExports = JiraExportUtils.convertStatistics(statistic);

    assertThat(launchStatisticExports).isNotEmpty().hasSize(3);
    assertThat(launchStatisticExports).extracting(LaunchStatisticExport::getStatus)
            .contains(Status.PASSED.value(),
                    Status.FAILED.value(),
                    Status.UNKNOWN.value())
            .doesNotContain(Status.SKIPPED.value(), Status.BROKEN.value());

    assertThat(launchStatisticExports).extracting(LaunchStatisticExport::getColor)
            .contains(ResultStatus.FAILED.color(),
                    ResultStatus.PASSED.color(),
                    ResultStatus.UNKNOWN.color())
            .doesNotContain(ResultStatus.SKIPPED.color(), ResultStatus.BROKEN.color());

    launchStatisticExports.forEach(launchStatisticExport -> assertThat(launchStatisticExport.getCount()).isEqualTo(resultCount));
}
 
Example #23
Source File: JunitXmlPlugin.java    From allure2 with Apache License 2.0 5 votes vote down vote up
private void parseTestCase(final TestSuiteInfo info, final XmlElement testCaseElement, final Path resultsDirectory,
                           final Path parsedFile, final RandomUidContext context, final ResultsVisitor visitor) {
    final String className = testCaseElement.getAttribute(CLASS_NAME_ATTRIBUTE_NAME);
    final Status status = getStatus(testCaseElement);
    final TestResult result = createStatuslessTestResult(info, testCaseElement, parsedFile, context);
    result.setStatus(status);
    result.setFlaky(isFlaky(testCaseElement));
    setStatusDetails(result, testCaseElement);
    final StageResult stageResult = new StageResult();
    getLogMessage(testCaseElement).ifPresent(logMessage -> {
        final List<String> lines = splitLines(logMessage);
        final List<Step> steps = lines
                .stream()
                .map(line -> new Step().setName(line))
                .collect(Collectors.toList());
        stageResult.setSteps(steps);
    });
    getLogFile(resultsDirectory, className)
            .filter(Files::exists)
            .map(visitor::visitAttachmentFile)
            .map(attachment1 -> attachment1.setName("System out"))
            .ifPresent(attachment -> stageResult.setAttachments(singletonList(attachment)));
    result.setTestStage(stageResult);
    visitor.visitTestResult(result);

    RETRIES.forEach((elementName, retryStatus) -> testCaseElement.get(elementName).forEach(failure -> {
        final TestResult retried = createStatuslessTestResult(info, testCaseElement, parsedFile, context);
        retried.setHidden(true);
        retried.setStatus(retryStatus);
        retried.setStatusMessage(failure.getAttribute(MESSAGE_ATTRIBUTE_NAME));
        retried.setStatusTrace(failure.getValue());
        visitor.visitTestResult(retried);
    }));
}
 
Example #24
Source File: TestData.java    From allure2 with Apache License 2.0 5 votes vote down vote up
public static TestResult createTestResult(final Status status) {
    return new TestResult()
            .setUid(RandomStringUtils.random(10))
            .setName(RandomStringUtils.random(10))
            .setHistoryId(RandomStringUtils.random(9))
            .setStatus(status);
}
 
Example #25
Source File: JiraLaunchExportPluginTest.java    From allure2 with Apache License 2.0 5 votes vote down vote up
@Test
void shouldExportLaunchToJira() {
    final LaunchResults launchResults = mock(LaunchResults.class);
    final TestResult passed = createTestResult(Status.PASSED);
    final TestResult failed = createTestResult(Status.FAILED);
    final TestResult broken = createTestResult(Status.BROKEN);
    final TestResult skipped = createTestResult(Status.SKIPPED);
    final TestResult unknown = createTestResult(Status.UNKNOWN);

    final Set<TestResult> results = new HashSet<>(Arrays.asList(passed, failed, broken, skipped, unknown));
    when(launchResults.getAllResults()).thenReturn(results);
    final Statistic statistic = JiraExportUtils.getStatistic(Arrays.asList(launchResults));
    final List<LaunchStatisticExport> launchStatisticExports = JiraExportUtils.convertStatistics(statistic);

    final ExecutorInfo executorInfo = new ExecutorInfo()
            .setBuildName(RandomStringUtils.random(10))
            .setReportUrl(RandomStringUtils.random(10));
    when(launchResults.getExtra("executor")).thenReturn(Optional.of(executorInfo));
    final JiraService service = TestData.mockJiraService();
    final JiraExportPlugin jiraLaunchExportPlugin = new JiraExportPlugin(
            true,
            "ALLURE-1,ALLURE-2",
            () -> service
    );

    jiraLaunchExportPlugin.aggregate(
            mock(Configuration.class),
            Collections.singletonList(launchResults),
            Paths.get("/")
    );

    verify(service, times(1)).createJiraLaunch(any(JiraLaunch.class), anyList());

    verify(service).createJiraLaunch(argThat(launch -> executorInfo.getBuildName().equals(launch.getExternalId())), anyList());
    verify(service).createJiraLaunch(argThat(launch -> executorInfo.getReportUrl().equals(launch.getUrl())), anyList());
    verify(service).createJiraLaunch(argThat(launch -> launchStatisticExports.equals(launch.getStatistic())), anyList());
    verify(service).createJiraLaunch(argThat(launch -> executorInfo.getBuildName().equals(launch.getName())), anyList());
    verify(service).createJiraLaunch(any(JiraLaunch.class), argThat(issues -> !issues.isEmpty()));

}
 
Example #26
Source File: JiraExportUtilitiesTest.java    From allure2 with Apache License 2.0 5 votes vote down vote up
@Test
public void testResultsFromLaunchResultsShouldConvertToLaunchStatisticExport() {
    final long resultCount = 1;
    final LaunchResults launchResults = mock(LaunchResults.class);
    final TestResult passed = createTestResult(Status.PASSED);
    final TestResult failed = createTestResult(Status.FAILED);
    final TestResult broken = createTestResult(Status.BROKEN);
    final TestResult skipped = createTestResult(Status.SKIPPED);
    final TestResult unknown = createTestResult(Status.UNKNOWN);

    final Set<TestResult> results = new HashSet<>(Arrays.asList(passed, failed, broken, skipped, unknown));
    when(launchResults.getAllResults()).thenReturn(results);

    final Statistic statistic = JiraExportUtils.getStatistic(Arrays.asList(launchResults));
    List<LaunchStatisticExport> launchStatisticExports = JiraExportUtils.convertStatistics(statistic);

    assertThat(launchStatisticExports).isNotEmpty().hasSize(5);

    assertThat(launchStatisticExports).extracting(LaunchStatisticExport::getStatus)
            .contains(Status.PASSED.value(),
                    Status.FAILED.value(),
                    Status.SKIPPED.value(),
                    Status.BROKEN.value(),
                    Status.UNKNOWN.value());

    assertThat(launchStatisticExports).extracting(LaunchStatisticExport::getColor)
            .contains(ResultStatus.FAILED.color(),
                    ResultStatus.PASSED.color(),
                    ResultStatus.SKIPPED.color(),
                    ResultStatus.BROKEN.color(),
                    ResultStatus.UNKNOWN.color());
    launchStatisticExports.forEach(launchStatisticExport -> assertThat(launchStatisticExport.getCount()).isEqualTo(resultCount));

}
 
Example #27
Source File: TrxPlugin.java    From allure2 with Apache License 2.0 5 votes vote down vote up
protected Status parseStatus(final String outcome) {
    if (Objects.isNull(outcome)) {
        return Status.UNKNOWN;
    }
    switch (outcome.toLowerCase()) {
        case "passed":
            return Status.PASSED;
        case "failed":
            return Status.FAILED;
        default:
            return Status.UNKNOWN;
    }
}
 
Example #28
Source File: ResultsUtils.java    From allure2 with Apache License 2.0 5 votes vote down vote up
private static Status getTestStatus(final Map<String, Object> props) {
    final Object status = props.get(TEST_STATUS);
    if (Objects.isNull(status)) {
        return Status.UNKNOWN;
    }
    if ("Success".equals(status)) {
        return Status.PASSED;
    }
    if ("Failure".equals(status)) {
        return Status.FAILED;
    }
    return Status.UNKNOWN;
}
 
Example #29
Source File: CucumberJsonResultsReader.java    From allure2 with Apache License 2.0 5 votes vote down vote up
private Status getStatus(final Element source) {
    if (source.getStatus().isPassed()) {
        return Status.PASSED;
    }
    if (Objects.nonNull(source.getSteps())) {
        return Stream.of(source.getSteps())
                .map(this::getStepStatus)
                .min(Enum::compareTo)
                .orElse(Status.UNKNOWN);
    }
    return getStatus(source.getStatus());
}
 
Example #30
Source File: HistoryTrendPluginTest.java    From allure2 with Apache License 2.0 5 votes vote down vote up
@Test
void shouldFindLatestExecutor() {
    final Map<String, Object> extra1 = new HashMap<>();
    final List<HistoryTrendItem> history1 = randomHistoryTrendItems();
    extra1.put(HISTORY_TREND_BLOCK_NAME, history1);
    extra1.put(EXECUTORS_BLOCK_NAME, new ExecutorInfo().setBuildOrder(1L));
    final Map<String, Object> extra2 = new HashMap<>();
    final List<HistoryTrendItem> history2 = randomHistoryTrendItems();
    extra2.put(HISTORY_TREND_BLOCK_NAME, history2);
    extra2.put(EXECUTORS_BLOCK_NAME, new ExecutorInfo().setBuildOrder(7L));

    final List<LaunchResults> launchResults = Arrays.asList(
            createLaunchResults(extra1,
                    randomTestResult().setStatus(Status.PASSED),
                    randomTestResult().setStatus(Status.FAILED),
                    randomTestResult().setStatus(Status.FAILED)
            ),
            createLaunchResults(extra2,
                    randomTestResult().setStatus(Status.PASSED),
                    randomTestResult().setStatus(Status.FAILED),
                    randomTestResult().setStatus(Status.FAILED)
            )
    );

    final List<HistoryTrendItem> data = new HistoryTrendPlugin().getData(launchResults);

    assertThat(data)
            .hasSize(1 + history1.size() + history2.size());

    final HistoryTrendItem historyTrendItem = data.get(0);

    assertThat(historyTrendItem)
            .hasFieldOrPropertyWithValue("buildOrder", 7L);
}