io.qameta.allure.model.Link Java Examples
The following examples show how to use
io.qameta.allure.model.Link.
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: AllureTest.java From allure-java with Apache License 2.0 | 6 votes |
@Test void shouldAddLinks() { final io.qameta.allure.model.Link first = random(Link.class); final io.qameta.allure.model.Link second = random(Link.class); final io.qameta.allure.model.Link third = random(Link.class); final AllureResults results = runWithinTestContext( () -> { link(first.getName(), first.getType(), first.getUrl()); link(second.getName(), second.getUrl()); link(third.getUrl()); }, Allure::setLifecycle ); assertThat(results.getTestResults()) .flatExtracting(TestResult::getLinks) .extracting(Link::getName, Link::getType, Link::getUrl) .contains( tuple(first.getName(), first.getType(), first.getUrl()), tuple(second.getName(), null, second.getUrl()), tuple(null, null, third.getUrl()) ); }
Example #2
Source File: AllureJunitPlatformTest.java From allure-java with Apache License 2.0 | 6 votes |
@AllureFeatures.Links @ResourceLock(value = SYSTEM_PROPERTIES, mode = READ_WRITE) @SystemProperty(name = "allure.link.issue.pattern", value = "https://example.org/issue/{}") @SystemProperty(name = "allure.link.tms.pattern", value = "https://example.org/tms/{}") @SystemProperty(name = "allure.link.custom.pattern", value = "https://example.org/custom/{}") @Test void shouldProcessClassLinks() { final AllureResults results = runClasses(TestWithClassLinks.class); final List<TestResult> testResults = results.getTestResults(); assertThat(testResults) .hasSize(1) .flatExtracting(TestResult::getLinks) .extracting(Link::getName, Link::getType, Link::getUrl) .contains( tuple("LINK-1", "custom", "https://example.org/custom/LINK-1"), tuple("LINK-2", "custom", "https://example.org/link/2"), tuple("", "custom", "https://example.org/some-custom-link"), tuple("ISSUE-1", "issue", "https://example.org/issue/ISSUE-1"), tuple("ISSUE-2", "issue", "https://example.org/issue/ISSUE-2"), tuple("ISSUE-3", "issue", "https://example.org/issue/ISSUE-3"), tuple("TMS-1", "tms", "https://example.org/tms/TMS-1"), tuple("TMS-2", "tms", "https://example.org/tms/TMS-2"), tuple("TMS-3", "tms", "https://example.org/tms/TMS-3") ); }
Example #3
Source File: AllureJunitPlatformTest.java From allure-java with Apache License 2.0 | 6 votes |
@AllureFeatures.Links @ResourceLock(value = SYSTEM_PROPERTIES, mode = READ_WRITE) @SystemProperty(name = "allure.link.issue.pattern", value = "https://example.org/issue/{}") @SystemProperty(name = "allure.link.tms.pattern", value = "https://example.org/tms/{}") @SystemProperty(name = "allure.link.custom.pattern", value = "https://example.org/custom/{}") @Test void shouldProcessMethodLinks() { final AllureResults results = runClasses(TestWithMethodLinks.class); final List<TestResult> testResults = results.getTestResults(); assertThat(testResults) .hasSize(1) .flatExtracting(TestResult::getLinks) .extracting(Link::getName, Link::getType, Link::getUrl) .contains( tuple("LINK-1", "custom", "https://example.org/custom/LINK-1"), tuple("LINK-2", "custom", "https://example.org/link/2"), tuple("", "custom", "https://example.org/some-custom-link"), tuple("ISSUE-1", "issue", "https://example.org/issue/ISSUE-1"), tuple("ISSUE-2", "issue", "https://example.org/issue/ISSUE-2"), tuple("ISSUE-3", "issue", "https://example.org/issue/ISSUE-3"), tuple("TMS-1", "tms", "https://example.org/tms/TMS-1"), tuple("TMS-2", "tms", "https://example.org/tms/TMS-2"), tuple("TMS-3", "tms", "https://example.org/tms/TMS-3") ); }
Example #4
Source File: AllureCucumber4JvmTest.java From allure-java with Apache License 2.0 | 6 votes |
@AllureFeatures.Links @ExtendWith(SystemPropertyExtension.class) @SystemProperty(name = "allure.link.issue.pattern", value = "https://example.org/issue/{}") @SystemProperty(name = "allure.link.tms.pattern", value = "https://example.org/tms/{}") @Test void shouldAddLinks() { final AllureResultsWriterStub writer = new AllureResultsWriterStub(); runFeature(writer, "features/tags.feature"); final List<TestResult> testResults = writer.getTestResults(); assertThat(testResults) .flatExtracting(TestResult::getLinks) .extracting(Link::getName, Link::getType, Link::getUrl) .contains( tuple("OAT-4444", "tms", "https://example.org/tms/OAT-4444"), tuple("BUG-22400", "issue", "https://example.org/issue/BUG-22400") ); }
Example #5
Source File: AllureCucumber3JvmTest.java From allure-java with Apache License 2.0 | 6 votes |
@AllureFeatures.Links @ExtendWith(SystemPropertyExtension.class) @SystemProperty(name = "allure.link.issue.pattern", value = "https://example.org/issue/{}") @SystemProperty(name = "allure.link.tms.pattern", value = "https://example.org/tms/{}") @Test void shouldAddLinks() { final AllureResults results = runFeature("features/tags.feature"); assertThat(results.getTestResults()) .flatExtracting(TestResult::getLinks) .extracting(Link::getName, Link::getType, Link::getUrl) .contains( tuple("OAT-4444", "tms", "https://example.org/tms/OAT-4444"), tuple("BUG-22400", "issue", "https://example.org/issue/BUG-22400") ); }
Example #6
Source File: AllureTestNgTest.java From allure-java with Apache License 2.0 | 6 votes |
@AllureFeatures.Links @Test(description = "Tests with links") public void linksTest() { final AllureResults results = runTestNgSuites("suites/links.xml"); List<TestResult> testResults = results.getTestResults(); assertThat(testResults) .hasSize(4) .filteredOn(hasLinks()) .hasSize(4) .flatExtracting(TestResult::getLinks) .extracting(Link::getName) .contains("testClass", "a", "b", "c", "testClassIssue", "testClassTmsLink", "testClass", "nested1", "nested2", "nested3", "testClassIssue", "issue1", "issue2", "issue3", "testClassTmsLink", "tms1", "tms2", "tms3", "testClass", "a", "b", "c", "testClassIssue", "testClassTmsLink", "testClass", "inheritedLink1", "inheritedLink2", "testClassIssue", "inheritedIssue", "testClassTmsLink", "inheritedTmsLink" ); }
Example #7
Source File: AllureCucumberJvmTest.java From allure-java with Apache License 2.0 | 6 votes |
@AllureFeatures.Links @ExtendWith(SystemPropertyExtension.class) @SystemProperty(name = "allure.link.issue.pattern", value = "https://example.org/issue/{}") @SystemProperty(name = "allure.link.tms.pattern", value = "https://example.org/tms/{}") @Test void shouldAddLinks() { final AllureResults results = runFeature("features/tags.feature"); final List<TestResult> testResults = results.getTestResults(); assertThat(testResults) .flatExtracting(TestResult::getLinks) .extracting(Link::getName, Link::getType, Link::getUrl) .contains( tuple("OAT-4444", "tms", "https://example.org/tms/OAT-4444"), tuple("BUG-22400", "issue", "https://example.org/issue/BUG-22400") ); }
Example #8
Source File: AllureCucumber5JvmTest.java From allure-java with Apache License 2.0 | 6 votes |
@AllureFeatures.Links @ExtendWith(SystemPropertyExtension.class) @SystemProperty(name = "allure.link.issue.pattern", value = "https://example.org/issue/{}") @SystemProperty(name = "allure.link.tms.pattern", value = "https://example.org/tms/{}") @Test void shouldAddLinks() { final AllureResultsWriterStub writer = new AllureResultsWriterStub(); runFeature(writer, "features/tags.feature"); final List<TestResult> testResults = writer.getTestResults(); assertThat(testResults) .flatExtracting(TestResult::getLinks) .extracting(Link::getName, Link::getType, Link::getUrl) .contains( tuple("OAT-4444", "tms", "https://example.org/tms/OAT-4444"), tuple("BUG-22400", "issue", "https://example.org/issue/BUG-22400") ); }
Example #9
Source File: AllureCucumber2JvmTest.java From allure-java with Apache License 2.0 | 6 votes |
@AllureFeatures.Links @ExtendWith(SystemPropertyExtension.class) @SystemProperty(name = "allure.link.issue.pattern", value = "https://example.org/issue/{}") @SystemProperty(name = "allure.link.tms.pattern", value = "https://example.org/tms/{}") @Test void shouldAddLinks() { final AllureResults results = runFeature("features/tags.feature"); final List<TestResult> testResults = results.getTestResults(); assertThat(testResults) .flatExtracting(TestResult::getLinks) .extracting(Link::getName, Link::getType, Link::getUrl) .contains( tuple("OAT-4444", "tms", "https://example.org/tms/OAT-4444"), tuple("BUG-22400", "issue", "https://example.org/issue/BUG-22400") ); }
Example #10
Source File: VividusLabelTests.java From vividus with Apache License 2.0 | 6 votes |
@ParameterizedTest @CsvSource({ "TEST_CASE_ID, tms", "ISSUE_ID, issue", "REQUIREMENT_ID, requirement" }) void shouldCreateLink(VividusLabel vividusLabel, String type) { String identifier = "VVD-5"; Optional<Link> optionalLink = vividusLabel.createLink(identifier); assertTrue(optionalLink.isPresent()); Link link = optionalLink.get(); assertAll( () -> assertEquals(identifier, link.getName()), () -> assertEquals(type, link.getType()), () -> assertEquals(HTTPS + type + "/" + identifier, link.getUrl()) ); }
Example #11
Source File: AllureSpockTest.java From allure-java with Apache License 2.0 | 5 votes |
@Test void shouldSetLinks() { final AllureResults results = run(FailedTest.class); assertThat(results.getTestResults()) .flatExtracting(TestResult::getLinks) .extracting(Link::getName) .containsExactlyInAnyOrder("link-1", "link-2", "issue-1", "issue-2", "tms-1", "tms-2"); }
Example #12
Source File: AnnotationUtils.java From allure-java with Apache License 2.0 | 5 votes |
private static Stream<Link> extractLinks(final LinkAnnotation m, final Annotation annotation) { // this is required as Link annotation uses name attribute as value alias. if (annotation instanceof io.qameta.allure.Link) { return Stream.of(createLink((io.qameta.allure.Link) annotation)); } if (Objects.equals(m.value(), LinkAnnotation.DEFAULT_VALUE)) { return callValueMethod(annotation) .map(value -> createLink(value, null, m.url(), m.type())); } return Stream.of(createLink(m.value(), null, m.url(), m.type())); }
Example #13
Source File: AllureStoryReporter.java From vividus with Apache License 2.0 | 5 votes |
private void stopTestCase() { if (allureRunContext.getScenarioExecutionStage() == ScenarioExecutionStage.IN_PROGRESS) { stopBddStep(StatusPriority.getLowest().getStatusModel()); } LinkedQueueItem<String> step = getLinkedStep(); if (!step.isRootItem()) { stopStep(); return; } String id = step.getValue(); String testRunId = getTestRunId(); if (testRunId != null) { Link testRunLink = ResultsUtils.createTmsLink(testRunId).setName("Test run ID"); lifecycle.updateTestCase(id, result -> result.getLinks().add(testRunLink)); } lifecycle.stopTestCase(id); lifecycle.writeTestCase(id); allureRunContext.resetScenarioExecutionStage(); switchToParent(); }
Example #14
Source File: AllureStoryReporterTests.java From vividus with Apache License 2.0 | 5 votes |
@Test void testAddTestCaseInfo() { mockScenarioUid(true); boolean givenStory = false; mockStoryStart(givenStory); Properties scenarioMeta = putTestCaseMetaProperties(getScenarioMeta(false), EXPECTED_SCENARIO_TEST_CASE_ID, EXPECTED_SCENARIO_REQUIREMENT_ID); Scenario scenario1 = createScenario(scenarioMeta, List.of()); Scenario scenario2 = createScenario(scenarioMeta, List.of()); RunningScenario runningScenario = getRunningScenario(scenario1, 0); Story story = new Story(STORY_NAME, null, new Meta(new Properties()), null, List.of(scenario1, scenario2)); RunningStory runningStory = getRunningStory(story, runningScenario); when(bddRunContext.getRunningStory()).thenReturn(runningStory); when(bddRunContext.getStoriesChain()).thenReturn(new LinkedList<>(List.of(runningStory))); allureStoryReporter.beforeStory(story, givenStory); allureStoryReporter.beforeScenario(story.getScenarios().get(0)); verify(allureLifecycle).scheduleTestCase(testResultCaptor.capture()); TestResult captured = testResultCaptor.getValue(); assertEquals("[batch: my-batch][stories-chain: name][scenario: Scenario-0]", captured.getHistoryId()); assertTestResultLabel(TEST_CASE_ID, EXPECTED_SCENARIO_TEST_CASE_ID); assertTestResultLabel(REQUIREMENT_ID, EXPECTED_SCENARIO_REQUIREMENT_ID); List<Link> links = captured.getLinks(); assertFalse(links.isEmpty()); assertEquals(TMS_LINK_PREFIX + EXPECTED_SCENARIO_TEST_CASE_ID, links.get(0).getUrl()); assertEquals(StatusPriority.getLowest().getStatusModel(), captured.getStatus()); }
Example #15
Source File: AllureStoryReporter.java From vividus with Apache License 2.0 | 5 votes |
@Override public void failed(String step, Throwable throwable) { super.failed(step, throwable); checkForBeforeAfterScenarioSteps(); if (!(throwable instanceof UUIDExceptionWrapper) || !(throwable.getCause() instanceof BeforeOrAfterFailed)) { modifyStepTitle(step); } Throwable cause = JBehaveFailureUnwrapper.unwrapCause(throwable); boolean isVerificationError = cause instanceof VerificationError; if (isVerificationError) { cause = verificationErrorAdapter.adapt((VerificationError) cause); List<Link> links = new ArrayList<>(); for (KnownIssue knownIssue: ((VerificationError) cause).getKnownIssues()) { if (!knownIssue.isPotentiallyKnown()) { links.add(ResultsUtils.createIssueLink(knownIssue.getIdentifier())); } } lifecycle.updateTestCase(getRootStepId(), result -> result.getLinks().addAll(links)); } stopBddStep(StatusProvider.getStatus(cause), getStatusDetailsFromThrowable(cause)); }
Example #16
Source File: Allure1TestCaseAspectsTest.java From allure-java with Apache License 2.0 | 5 votes |
@ParameterizedTest @MethodSource("testClassesProvider") void shouldProcessIssuesAnnotation(final SimpleTest simpleTest) { final AllureResults results = runWithinTestContext( simpleTest::testSomething, Allure1TestCaseAspects::setLifecycle, Allure1ParametersAspects::setLifecycle ); assertThat(results.getTestResults()) .flatExtracting(TestResult::getLinks) .extracting(Link::getName) .containsExactlyInAnyOrder("ISSUE-1", "ISSUE-11", "ISSUE-2", "ISSUE-22", "TEST-1"); }
Example #17
Source File: Allure1Annotations.java From allure-java with Apache License 2.0 | 5 votes |
public List<Link> getLinks() { final Method method = getMethod(); final List<Link> links = new ArrayList<>(); links.addAll(Allure1Utils.getLinks(method, TestCaseId.class, Allure1Utils::createLinks)); links.addAll(Allure1Utils.getLinks(method, Issue.class, Allure1Utils::createLinks)); links.addAll(Allure1Utils.getLinks(method, Issues.class, Allure1Utils::createLinks)); return links; }
Example #18
Source File: AllureTestNg.java From allure-java with Apache License 2.0 | 5 votes |
private List<Link> getLinks(final ITestNGMethod method, final IClass iClass) { final List<Link> links = new ArrayList<>(); getMethod(method) .map(AnnotationUtils::getLinks) .ifPresent(links::addAll); getClass(iClass) .map(AnnotationUtils::getLinks) .ifPresent(links::addAll); return links; }
Example #19
Source File: ResultsUtils.java From allure-java with Apache License 2.0 | 5 votes |
@SuppressWarnings("PMD.UseObjectForClearerAPI") public static Link createLink(final String value, final String name, final String url, final String type) { final String resolvedName = firstNonEmpty(value).orElse(name); final String resolvedUrl = firstNonEmpty(url) .orElseGet(() -> getLinkUrl(resolvedName, type)); return new Link() .setName(resolvedName) .setUrl(resolvedUrl) .setType(type); }
Example #20
Source File: Allure1Utils.java From allure-java with Apache License 2.0 | 5 votes |
private static <T extends Annotation> List<Link> getLinks(final AnnotatedElement element, final Class<T> annotation, final Function<T, List<Link>> extractor) { return element.isAnnotationPresent(annotation) ? extractor.apply(element.getAnnotation(annotation)) : Collections.emptyList(); }
Example #21
Source File: Allure1Utils.java From allure-java with Apache License 2.0 | 5 votes |
public static <T extends Annotation> List<Link> getLinks(final Method method, final Class<T> annotation, final Function<T, List<Link>> extractor) { final List<Link> labels = new ArrayList<>(); labels.addAll(getLinks((AnnotatedElement) method, annotation, extractor)); labels.addAll(getLinks(method.getDeclaringClass(), annotation, extractor)); return labels; }
Example #22
Source File: AllureJunit4Test.java From allure-java with Apache License 2.0 | 5 votes |
@Test @AllureFeatures.Links void shouldSetLinks() { final AllureResults results = runClasses(FailedTest.class); List<TestResult> testResults = results.getTestResults(); assertThat(testResults) .hasSize(1) .flatExtracting(TestResult::getLinks) .extracting(Link::getName) .containsExactlyInAnyOrder("link-1", "link-2", "issue-1", "issue-2", "tms-1", "tms-2"); }
Example #23
Source File: AllureJunit4.java From allure-java with Apache License 2.0 | 5 votes |
private List<Link> extractLinks(final Description description) { final List<Link> result = new ArrayList<>(getLinks(description.getAnnotations())); Optional.of(description) .map(Description::getTestClass) .map(AnnotationUtils::getLinks) .ifPresent(result::addAll); return result; }
Example #24
Source File: AllureCitrus.java From allure-java with Apache License 2.0 | 5 votes |
private List<Link> getLinks(final AnnotatedElement annotatedElement) { return Stream.of( getAnnotations(annotatedElement, io.qameta.allure.Link.class).map(ResultsUtils::createLink), getAnnotations(annotatedElement, io.qameta.allure.Issue.class).map(ResultsUtils::createLink), getAnnotations(annotatedElement, io.qameta.allure.TmsLink.class).map(ResultsUtils::createLink)) .reduce(Stream::concat).orElseGet(Stream::empty).collect(Collectors.toList()); }
Example #25
Source File: ResultsUtils.java From allure-java with Apache License 2.0 | 4 votes |
public static Link createIssueLink(final String value) { return createLink(value, null, null, ISSUE_LINK_TYPE); }
Example #26
Source File: Allure.java From allure-java with Apache License 2.0 | 4 votes |
/** * @deprecated use {@link #link(String, String, String)} instead. */ @Deprecated public static void addLinks(final Link... links) { getLifecycle().updateTestCase(testResult -> testResult.getLinks().addAll(asList(links))); }
Example #27
Source File: ResultsUtils.java From allure-java with Apache License 2.0 | 4 votes |
public static Link createTmsLink(final String value) { return createLink(value, null, null, TMS_LINK_TYPE); }
Example #28
Source File: ResultsUtils.java From allure-java with Apache License 2.0 | 4 votes |
public static Link createLink(final io.qameta.allure.Link link) { return createLink(link.value(), link.name(), link.url(), link.type()); }
Example #29
Source File: ResultsUtils.java From allure-java with Apache License 2.0 | 4 votes |
public static Link createLink(final io.qameta.allure.Issue link) { return createIssueLink(link.value()); }
Example #30
Source File: ResultsUtils.java From allure-java with Apache License 2.0 | 4 votes |
public static Link createLink(final io.qameta.allure.TmsLink link) { return createTmsLink(link.value()); }