io.qameta.allure.model.TestResult Java Examples

The following examples show how to use io.qameta.allure.model.TestResult. 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: AllureCucumber4JvmTest.java    From allure-java with Apache License 2.0 6 votes vote down vote up
@AllureFeatures.BrokenTests
@Test
void shouldHandleAmbigiousStepsExceptions() {
    final AllureResultsWriterStub writer = new AllureResultsWriterStub();
    runFeature(writer, "features/ambigious.feature");

    final List<TestResult> testResults = writer.getTestResults();
    assertThat(testResults)
            .extracting(TestResult::getName, TestResult::getStatus)
            .containsExactlyInAnyOrder(
                    tuple("Simple scenario with ambigious steps", Status.SKIPPED)
            );

    assertThat(testResults.get(0).getSteps())
            .extracting(StepResult::getName, StepResult::getStatus)
            .containsExactly(
                    tuple("When  ambigious step present", null),
                    tuple("Then  something bad should happen", Status.SKIPPED)
            );
}
 
Example #2
Source File: AllureJunitPlatformTest.java    From allure-java with Apache License 2.0 6 votes vote down vote up
@Test
@AllureFeatures.Steps
void shouldAddSteps() {
    final AllureResults results = runClasses(TestWithSteps.class);

    final List<TestResult> testResults = results.getTestResults();
    assertThat(testResults)
            .hasSize(1);

    final TestResult testResult = testResults.get(0);
    assertThat(testResult.getSteps())
            .hasSize(3)
            .flatExtracting(StepResult::getName)
            .containsExactly("first", "second", "third");

}
 
Example #3
Source File: AllureCucumber2JvmTest.java    From allure-java with Apache License 2.0 6 votes vote down vote up
@AllureFeatures.MarkerAnnotations
@Test
void shouldCommonLabels() {
    final AllureResults results = runFeature("features/tags.feature");

    final List<TestResult> testResults = results.getTestResults();

    assertThat(testResults)
            .flatExtracting(TestResult::getLabels)
            .extracting(Label::getName, Label::getValue)
            .contains(
                    tuple("package", "Test Simple Scenarios"),
                    tuple("suite", "Test Simple Scenarios"),
                    tuple("testClass", "Add a to b")
            );
}
 
Example #4
Source File: AllureCucumber2JvmTest.java    From allure-java with Apache License 2.0 6 votes vote down vote up
@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 #5
Source File: AllureCucumber3JvmTest.java    From allure-java with Apache License 2.0 6 votes vote down vote up
@AllureFeatures.Parameters
@Test
void shouldHandleMultipleExamplesPerOutline() throws IOException {
    final AllureResults results = runFeature("features/multi-examples.feature");

    final List<TestResult> testResults = results.getTestResults();

    assertThat(testResults)
            .hasSize(2);

    assertThat(testResults)
            .flatExtracting(TestResult::getParameters)
            .extracting(Parameter::getName, Parameter::getValue)
            .containsExactlyInAnyOrder(
                    tuple("a", "1"), tuple("b", "3"), tuple("result", "4"),
                    tuple("a", "2"), tuple("b", "4"), tuple("result", "6")
            );
}
 
Example #6
Source File: AllureCucumberJvmTest.java    From allure-java with Apache License 2.0 6 votes vote down vote up
@AllureFeatures.Descriptions
@Test
void shouldSetDescription() {
    final AllureResults results = runFeature("features/description.feature");

    final String expected = "\nThis is description for current feature.\n"
            + "It should appear on each scenario in report";

    final List<TestResult> testResults = results.getTestResults();
    assertThat(testResults)
            .extracting(TestResult::getDescription)
            .containsExactlyInAnyOrder(
                    expected,
                    expected
            );
}
 
Example #7
Source File: AllureTestNgTest.java    From allure-java with Apache License 2.0 6 votes vote down vote up
@AllureFeatures.Descriptions
@Test(description = "Javadoc description with line separation")
public void descriptionsWithLineSeparationTest() {
    String initialSeparateLines = System.getProperty(ALLURE_SEPARATE_LINES_SYSPROP);
    if (!Boolean.parseBoolean(initialSeparateLines)) {
        System.setProperty(ALLURE_SEPARATE_LINES_SYSPROP, "true");
    }
    try {
        final String testDescription = "Sample test description<br /> - next line<br /> - another line<br />";
        final AllureResults results = runTestNgSuites("suites/descriptions-test.xml");
        List<TestResult> testResult = results.getTestResults();

        assertThat(testResult).as("Test case result has not been written")
                .hasSize(2)
                .filteredOn(result -> result.getName().equals("testSeparated"))
                .extracting(result -> result.getDescriptionHtml().trim())
                .as("Javadoc description of test case has not been processed correctly")
                .contains(testDescription);
    } finally {
        System.setProperty(ALLURE_SEPARATE_LINES_SYSPROP, String.valueOf(initialSeparateLines));
    }
}
 
Example #8
Source File: AllureJunit5Test.java    From allure-java with Apache License 2.0 6 votes vote down vote up
@Test
void shouldSupportFailureInAfterEachFixture() {
    final AllureResults results = runClasses(AfterEachFixtureFailureSupport.class);

    assertThat(results.getTestResults())
            .hasSize(1);

    final TestResult testResult = results.getTestResults().get(0);

    assertThat(results.getTestResultContainers())
            .filteredOn("name", testResult.getName())
            .flatExtracting(TestResultContainer::getChildren)
            .contains(testResult.getUuid());

    assertThat(results.getTestResultContainers())
            .filteredOn("name", testResult.getName())
            .flatExtracting(TestResultContainer::getAfters)
            .extracting(FixtureResult::getName, FixtureResult::getStatus, f -> f.getStatusDetails().getMessage())
            .containsExactly(
                    tuple("tearDown", Status.BROKEN, "ta da")
            );
}
 
Example #9
Source File: AllureCitrusTest.java    From allure-java with Apache License 2.0 6 votes vote down vote up
@AllureFeatures.Steps
@Test
void shouldAddAllureSteps() {
    final DefaultTestDesigner designer = new DefaultTestDesigner();
    designer.name("Simple test");
    designer.action(new AbstractTestAction() {
        @Override
        public void doExecute(final TestContext context) {
            Allure.step("a");
            Allure.step("b");
            Allure.step("c");
        }
    });

    final AllureResults results = run(designer);
    assertThat(results.getTestResults())
            .flatExtracting(TestResult::getSteps)
            .flatExtracting(StepResult::getSteps)
            .extracting(StepResult::getName)
            .containsExactly("a", "b", "c");
}
 
Example #10
Source File: AllureCucumberJvmTest.java    From allure-java with Apache License 2.0 6 votes vote down vote up
@AllureFeatures.Attachments
@Test
void shouldAddAttachments() {
    final AllureResults results = runFeature("features/attachments.feature");

    final List<Attachment> attachments = results.getTestResults().stream()
            .map(TestResult::getSteps)
            .flatMap(Collection::stream)
            .map(StepResult::getAttachments)
            .flatMap(Collection::stream)
            .collect(Collectors.toList());

    assertThat(attachments)
            .extracting(Attachment::getName, Attachment::getType)
            .containsExactlyInAnyOrder(
                    tuple("Text output", "text/plain"),
                    tuple("Screenshot", null)
            );

    final List<String> attachmentContents = results.getAttachments().values().stream()
            .map(bytes -> new String(bytes, StandardCharsets.UTF_8))
            .collect(Collectors.toList());

    assertThat(attachmentContents)
            .containsExactlyInAnyOrder("text attachment", "image attachment");
}
 
Example #11
Source File: AllureJunitPlatformTest.java    From allure-java with Apache License 2.0 6 votes vote down vote up
@Test
@AllureFeatures.BrokenTests
void shouldProcessBrokenTests() {
    final AllureResults results = runClasses(BrokenTests.class);

    final List<TestResult> testResults = results.getTestResults();
    assertThat(testResults)
            .hasSize(1);

    final TestResult testResult = testResults.get(0);
    assertThat(testResult)
            .isNotNull()
            .hasFieldOrPropertyWithValue("name", "brokenTest()")
            .hasFieldOrPropertyWithValue("status", Status.BROKEN);

    assertThat(testResult.getStatusDetails())
            .hasFieldOrPropertyWithValue("message", "Make the test broken")
            .hasFieldOrProperty("trace");
}
 
Example #12
Source File: AllureTestNgTest.java    From allure-java with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
@AllureFeatures.Parameters
@Issue("128")
@Test
public void shouldProcessArrayParameters() {
    final AllureResults results = runTestNgSuites("suites/gh-128.xml");

    assertThat(results.getTestResults())
            .flatExtracting(TestResult::getParameters)
            .extracting(Parameter::getName, Parameter::getValue)
            .containsExactlyInAnyOrder(
                    tuple("first", "a"),
                    tuple("second", "false"),
                    tuple("third", "[1, 2, 3]")
            );
}
 
Example #13
Source File: AllureJunit5Test.java    From allure-java with Apache License 2.0 6 votes vote down vote up
@Test
void shouldSupportBeforeAllFixture() {
    final AllureResults results = runClasses(AllFixtureSupport.class);
    assertThat(results.getTestResults())
            .hasSize(1);

    final TestResult testResult = results.getTestResults().get(0);

    assertThat(results.getTestResultContainers())
            .filteredOn("name", "AllFixtureSupport")
            .flatExtracting(TestResultContainer::getChildren)
            .contains(testResult.getUuid());

    assertThat(results.getTestResultContainers())
            .filteredOn("name", "AllFixtureSupport")
            .flatExtracting(TestResultContainer::getBefores)
            .extracting(FixtureResult::getName, FixtureResult::getStatus)
            .containsExactly(
                    tuple("setUpAll", Status.PASSED)
            );
}
 
Example #14
Source File: AllureCucumber5JvmTest.java    From allure-java with Apache License 2.0 6 votes vote down vote up
@AllureFeatures.Descriptions
@Test
void shouldSetDescription() {
    final AllureResultsWriterStub writer = new AllureResultsWriterStub();
    runFeature(writer, "features/description.feature");

    final String expected = "This is description for current feature.\n"
            + "It should appear on each scenario in report";

    final List<TestResult> testResults = writer.getTestResults();
    assertThat(testResults)
            .extracting(TestResult::getDescription)
            .containsExactlyInAnyOrder(
                    expected,
                    expected
            );
}
 
Example #15
Source File: AllureTestNgTest.java    From allure-java with Apache License 2.0 6 votes vote down vote up
@AllureFeatures.SkippedTests
@Test(description = "Skipped suite")
public void skippedSuiteTest() {
    final Condition<StepResult> skipReason = new Condition<>(step ->
            step.getStatusDetails().getTrace().startsWith("java.lang.RuntimeException: Skip all"),
            "Suite should be skipped because of an exception in before suite");

    final AllureResults results = runTestNgSuites("suites/skipped-suite.xml");
    List<TestResult> testResults = results.getTestResults();
    List<TestResultContainer> testContainers = results.getTestResultContainers();
    assertThat(testResults)
            .extracting(TestResult::getName, TestResult::getStatus)
            .contains(
                    tuple("skippedTest", Status.SKIPPED),
                    tuple("testWithOneStep", Status.SKIPPED)
            );
    assertThat(testContainers).as("Unexpected quantity of testng containers has been written").hasSize(4);

    assertThat(findTestContainerByName(results, "Test suite 8").getBefores())
            .as("Before suite container should have a before method with one step")
            .hasSize(1)
            .flatExtracting(FixtureResult::getSteps)
            .hasSize(1).first()
            .hasFieldOrPropertyWithValue("status", Status.BROKEN)
            .has(skipReason);
}
 
Example #16
Source File: AllureJbehaveTest.java    From allure-java with Apache License 2.0 6 votes vote down vote up
@Issue("163")
@Test
void shouldNotFailIfGivenStoriesSpecified() {
    final AllureResults results = runStories("stories/given.story");

    assertThat(results.getTestResults())
            .extracting(TestResult::getName, TestResult::getStatus)
            .containsExactly(tuple("Add a to b", Status.PASSED));

    assertThat(results.getTestResults())
            .flatExtracting(TestResult::getSteps)
            .extracting(StepResult::getName)
            .containsExactly(
                    "Given a is 5",
                    "Given b is 10",
                    "When I add a to b",
                    "Then result is 15"
            );

}
 
Example #17
Source File: AllureCucumber5JvmTest.java    From allure-java with Apache License 2.0 6 votes vote down vote up
@AllureFeatures.Parameters
@Test
void shouldSupportTaggedExamplesBlocks() {
    final AllureResultsWriterStub writer = new AllureResultsWriterStub();
    runFeature(writer, "features/multi-examples.feature", "--tags", "@ExamplesTag2");

    final List<TestResult> testResults = writer.getTestResults();

    assertThat(testResults)
            .hasSize(1);

    assertThat(testResults)
            .flatExtracting(TestResult::getLabels)
            .extracting(Label::getName, Label::getValue)
            .contains(
                    tuple("tag", "ExamplesTag2")
            );

    assertThat(testResults)
            .flatExtracting(TestResult::getParameters)
            .extracting(Parameter::getName, Parameter::getValue)
            .containsExactlyInAnyOrder(
                    tuple("a", "2"), tuple("b", "4"), tuple("result", "6")
            );
}
 
Example #18
Source File: AllureCucumber4JvmTest.java    From allure-java with Apache License 2.0 6 votes vote down vote up
@AllureFeatures.SkippedTests
@AllureFeatures.Steps
@Test
void shouldProcessPendingExceptionsInSteps() {
    final AllureResultsWriterStub writer = new AllureResultsWriterStub();
    runFeature(writer, "features/pending.feature");

    final List<TestResult> testResults = writer.getTestResults();
    assertThat(testResults)
            .extracting(TestResult::getStatus)
            .containsExactlyInAnyOrder(Status.SKIPPED);

    assertThat(testResults.get(0).getSteps())
            .extracting(StepResult::getName, StepResult::getStatus)
            .containsExactlyInAnyOrder(
                    tuple("Given  a is 5", Status.PASSED),
                    tuple("When  step is yet to be implemented", Status.SKIPPED),
                    tuple("Then  b is 10", Status.SKIPPED)
            );
}
 
Example #19
Source File: StepsAspectsTest.java    From allure-java with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
@Test
void shouldProcessExceptions() {
    final AllureResults results = runWithinTestContext(() -> stepWithException());

    assertThat(results.getTestResults())
            .hasSize(1)
            .flatExtracting(TestResult::getSteps)
            .extracting(
                    StepResult::getName,
                    StepResult::getStatus,
                    step -> step.getStatusDetails().getMessage()
            )
            .containsExactly(
                    tuple("stepWithException", Status.BROKEN, "some exception")
            );
}
 
Example #20
Source File: AllureCucumber5JvmTest.java    From allure-java with Apache License 2.0 6 votes vote down vote up
@AllureFeatures.SkippedTests
@AllureFeatures.Steps
@Test
void shouldProcessPendingExceptionsInSteps() {
    final AllureResultsWriterStub writer = new AllureResultsWriterStub();
    runFeature(writer, "features/pending.feature");

    final List<TestResult> testResults = writer.getTestResults();
    assertThat(testResults)
            .extracting(TestResult::getStatus)
            .containsExactlyInAnyOrder(Status.SKIPPED);

    assertThat(testResults.get(0).getSteps())
            .extracting(StepResult::getName, StepResult::getStatus)
            .containsExactlyInAnyOrder(
                    tuple("Given  a is 5", Status.PASSED),
                    tuple("When  step is yet to be implemented", Status.SKIPPED),
                    tuple("Then  b is 10", Status.SKIPPED)
            );
}
 
Example #21
Source File: AllureCucumber5JvmTest.java    From allure-java with Apache License 2.0 5 votes vote down vote up
@AllureFeatures.History
@Test
void shouldPersistHistoryIdForScenarios() {
    final AllureResultsWriterStub writer = new AllureResultsWriterStub();
    runFeature(writer, "features/simple.feature");

    final List<TestResult> testResults = writer.getTestResults();
    assertThat(testResults.get(0).getHistoryId())
            .isEqualTo("8eea9ed4458a49d418859d1398580671");
}
 
Example #22
Source File: AllureCucumberJvmTest.java    From allure-java with Apache License 2.0 5 votes vote down vote up
@AllureFeatures.FailedTests
@Test
void shouldSetFailedStatus() {
    final AllureResults results = runFeature("features/failed.feature");

    final List<TestResult> testResults = results.getTestResults();
    assertThat(testResults)
            .extracting(TestResult::getStatus)
            .containsExactlyInAnyOrder(Status.FAILED);
}
 
Example #23
Source File: AllureTestNgTest.java    From allure-java with Apache License 2.0 5 votes vote down vote up
@AllureFeatures.Descriptions
@Test(description = "Javadoc description of tests with the same names")
public void javadocDescriptionsOfTestsWithTheSameNames() {
    final AllureResults results = runTestNgSuites("suites/descriptions-test-two-classes.xml");
    List<TestResult> testResults = results.getTestResults();

    checkTestJavadocDescriptions(testResults, "io.qameta.allure.testng.samples.DescriptionsTest.test", "Sample test description");

    checkTestJavadocDescriptions(testResults, "io.qameta.allure.testng.samples.DescriptionsAnotherTest.test", "Sample test description from DescriptionsAnotherTest");
}
 
Example #24
Source File: AllureOkHttp3Test.java    From allure-java with Apache License 2.0 5 votes vote down vote up
@Test
void shouldCreateRequestAttachment() {
    final Request request = new Request.Builder()
            .url(server.url("hello"))
            .build();

    final AllureResults results = execute(request, checkBody(BODY_STRING));

    assertThat(results.getTestResults())
            .flatExtracting(TestResult::getAttachments)
            .extracting(Attachment::getName)
            .contains("Request");
}
 
Example #25
Source File: AllureJunitPlatformTest.java    From allure-java with Apache License 2.0 5 votes vote down vote up
@Test
@AllureFeatures.DisplayName
void shouldProcessDefaultTestClassDisplayName() {
    final AllureResults results = runClasses(TestClassWithoutDisplayNameAnnotation.class);

    final List<TestResult> testResults = results.getTestResults();
    assertThat(testResults)
            .flatExtracting(TestResult::getLabels)
            .filteredOn("name", SUITE_LABEL_NAME)
            .extracting(Label::getValue)
            .contains("io.qameta.allure.junitplatform.features.TestClassWithoutDisplayNameAnnotation");
}
 
Example #26
Source File: StepsAspectsTest.java    From allure-java with Apache License 2.0 5 votes vote down vote up
@Test
void shouldUseMethodName() {
    final AllureResults results = runWithinTestContext(() -> stepWithDefaultName());

    assertThat(results.getTestResults())
            .hasSize(1)
            .flatExtracting(TestResult::getSteps)
            .extracting(StepResult::getName)
            .containsExactly("stepWithDefaultName");
}
 
Example #27
Source File: AllureSpockTest.java    From allure-java with Apache License 2.0 5 votes vote down vote up
@Test
void shouldProcessBrokenTest() {
    final AllureResults results = run(BrokenTest.class);
    assertThat(results.getTestResults())
            .extracting(TestResult::getStatus)
            .containsExactly(Status.BROKEN);
}
 
Example #28
Source File: AllureJunit4Test.java    From allure-java with Apache License 2.0 5 votes vote down vote up
@Test
@AllureFeatures.Trees
void shouldSetSuiteName() {
    final AllureResults results = runClasses(OneTest.class);
    List<TestResult> testResults = results.getTestResults();
    assertThat(testResults)
            .hasSize(1)
            .flatExtracting(TestResult::getLabels)
            .filteredOn(label -> "suite".equals(label.getName()))
            .extracting(Label::getValue)
            .containsExactly("Should be overwritten by method annotation");
}
 
Example #29
Source File: AllureCucumber3JvmTest.java    From allure-java with Apache License 2.0 5 votes vote down vote up
@AllureFeatures.MarkerAnnotations
@Test
void shouldAddBddLabels() {
    final AllureResults results = runFeature("features/tags.feature");

    assertThat(results.getTestResults())
            .flatExtracting(TestResult::getLabels)
            .extracting(Label::getName, Label::getValue)
            .contains(
                    tuple("feature", "Test Simple Scenarios"),
                    tuple("story", "Add a to b")
            );
}
 
Example #30
Source File: AllureSpockTest.java    From allure-java with Apache License 2.0 5 votes vote down vote up
@Test
void shouldSetTestFullName() {
    final AllureResults results = run(OneTest.class);
    assertThat(results.getTestResults())
            .extracting(TestResult::getFullName)
            .containsExactly("io.qameta.allure.spock.samples.OneTest.Simple Test");
}