io.qameta.allure.model.StepResult Java Examples
The following examples show how to use
io.qameta.allure.model.StepResult.
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: Allure1StepsAspectsTest.java From allure-java with Apache License 2.0 | 6 votes |
@Test void shouldSetupStepTitleFromAnnotation() { final AllureResults results = runWithinTestContext( () -> stepWithTitleAndWithParameter("parameter value"), Allure1StepsAspects::setLifecycle ); assertThat(results.getTestResults()) .flatExtracting(TestResult::getSteps) .extracting(StepResult::getName) .containsExactly("step with title and parameter [parameter value]"); assertThat(results.getTestResults()) .flatExtracting(TestResult::getSteps) .flatExtracting(StepResult::getParameters) .extracting("name", "value") .containsExactly(tuple("parameter", "parameter value")); }
Example #2
Source File: AllureStoryReporter.java From vividus with Apache License 2.0 | 6 votes |
private void startStep(String stepTitle, boolean checkForLifecycleSteps) { if (checkForLifecycleSteps) { StoryExecutionStage storyExecutionStage = allureRunContext.getStoryExecutionStage(); if (storyExecutionStage == null) { startTestCase("Lifecycle: Before story", StoryExecutionStage.LIFECYCLE_BEFORE_STORY_STEPS); } else if (storyExecutionStage == StoryExecutionStage.AFTER_SCENARIO) { startTestCase("Lifecycle: After story", StoryExecutionStage.LIFECYCLE_AFTER_STORY_STEPS); } } StepResult stepResult = new StepResult().setName(stepTitle).setStatus( StatusPriority.getLowest().getStatusModel()); String parentStepId = getCurrentStepId(); String childStepId = parentStepId + "-" + Thread.currentThread().getId(); lifecycle.startStep(parentStepId, childStepId, stepResult); putCurrentStepId(childStepId); }
Example #3
Source File: AllureLifecycle.java From allure-java with Apache License 2.0 | 6 votes |
/** * Stops step by given uuid. * * @param uuid the uuid of step to stop. */ public void stopStep(final String uuid) { final Optional<StepResult> found = storage.getStep(uuid); if (!found.isPresent()) { LOGGER.error("Could not stop step: step with uuid {} not found", uuid); return; } final StepResult step = found.get(); notifier.beforeStepStop(step); step.setStage(Stage.FINISHED); step.setStop(System.currentTimeMillis()); storage.remove(uuid); threadContext.stop(); notifier.afterStepStop(step); }
Example #4
Source File: AllureCucumber5JvmTest.java From allure-java with Apache License 2.0 | 6 votes |
@AllureFeatures.Steps @Test void shouldProcessUndefinedSteps() { final AllureResultsWriterStub writer = new AllureResultsWriterStub(); runFeature(writer, "features/undefined.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 undefined", null), tuple("Then b is 10", Status.SKIPPED) ); }
Example #5
Source File: AllureLifecycle.java From allure-java with Apache License 2.0 | 6 votes |
/** * Start a new step as child of specified parent. * * @param parentUuid the uuid of parent test case or step. * @param uuid the uuid of step. * @param result the step. */ public void startStep(final String parentUuid, final String uuid, final StepResult result) { notifier.beforeStepStart(result); result.setStage(Stage.RUNNING); result.setStart(System.currentTimeMillis()); threadContext.start(uuid); storage.put(uuid, result); storage.get(parentUuid, WithSteps.class).ifPresent(parentStep -> { synchronized (storage) { parentStep.getSteps().add(result); } }); notifier.afterStepStart(result); }
Example #6
Source File: AllureCucumber2JvmTest.java From allure-java with Apache License 2.0 | 6 votes |
@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 #7
Source File: AllureTestNgTest.java From allure-java with Apache License 2.0 | 6 votes |
@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 #8
Source File: AllureCucumber5JvmTest.java From allure-java with Apache License 2.0 | 6 votes |
@AllureFeatures.Base @Test void shouldSupportDryRunForSimpleFeatures() { final AllureResultsWriterStub writer = new AllureResultsWriterStub(); runFeature(writer, "features/simple.feature", "--dry-run"); final List<TestResult> testResults = writer.getTestResults(); assertThat(testResults) .extracting(TestResult::getName, TestResult::getStatus) .containsExactlyInAnyOrder( tuple("Add a to b", Status.SKIPPED) ); assertThat(testResults.get(0).getSteps()) .extracting(StepResult::getName, StepResult::getStatus) .containsExactlyInAnyOrder( tuple("Given a is 5", Status.SKIPPED), tuple("And b is 10", Status.SKIPPED), tuple("When I add a to b", Status.SKIPPED), tuple("Then result is 15", Status.SKIPPED) ); }
Example #9
Source File: AllureJbehaveTest.java From allure-java with Apache License 2.0 | 6 votes |
@SuppressWarnings("unchecked") @Test void shouldAddNotPerformedSteps() { final AllureResults results = runStories("stories/long.story"); assertThat(results.getTestResults()) .flatExtracting(TestResult::getSteps) .extracting(StepResult::getName, StepResult::getStatus) .containsExactly( tuple("Given a is 5", Status.PASSED), tuple("And b is 10", Status.PASSED), tuple("When I add a to b", Status.PASSED), tuple("Then result is 15", Status.PASSED), tuple("Then result is 15", Status.PASSED), tuple("When I add a to b", Status.PASSED), tuple("Then result is 20", Status.FAILED), tuple("Then result is ⦅21⦆", null), tuple("Then result is ⦅22⦆", null), tuple("Then result is ⦅23⦆", null), tuple("When I add a to b", null), tuple("Then result is ⦅25⦆", null) ); }
Example #10
Source File: StepsAspectsTest.java From allure-java with Apache License 2.0 | 6 votes |
@Test void shouldTransformPlaceholdersToPropertyValues() { final AllureResults results = runWithinTestContext(() -> { final DummyEmail[] emails = new DummyEmail[]{ new DummyEmail("[email protected]", asList("txt", "png")), new DummyEmail("[email protected]", asList("jpg", "mp4")), null }; final DummyCard card = new DummyCard("1111222233334444"); loginWith(new DummyUser(emails, "12345678", card), true); }); assertThat(results.getTestResults()) .flatExtracting(TestResult::getSteps) .extracting(StepResult::getName) .containsExactly("\"[[email protected], [email protected], null]\"," + " \"[{address='[email protected]', attachments='[txt, png]'}," + " {address='[email protected]', attachments='[jpg, mp4]'}," + " null]\"," + " \"[[txt, png], [jpg, mp4], null]\"," + " \"12345678\", \"{}\"," + " \"1111222233334444\", \"{missing}\", true"); }
Example #11
Source File: AllureTestNgTest.java From allure-java with Apache License 2.0 | 6 votes |
@AllureFeatures.FailedTests @Test(description = "Test failing by assertion") public void failingByAssertion() { String testName = "failingByAssertion"; final AllureResults results = runTestNgSuites("suites/failing-by-assertion.xml"); List<TestResult> testResult = results.getTestResults(); assertThat(testResult).as("Test case result has not been written").hasSize(1); assertThat(testResult.get(0)).as("Unexpected failed testng property") .hasFieldOrPropertyWithValue("status", Status.FAILED) .hasFieldOrPropertyWithValue("stage", Stage.FINISHED) .hasFieldOrPropertyWithValue("name", testName); assertThat(testResult) .flatExtracting(TestResult::getSteps) .hasSize(2) .extracting(StepResult::getStatus) .contains(Status.PASSED, Status.FAILED); }
Example #12
Source File: AllureCitrusTest.java From allure-java with Apache License 2.0 | 6 votes |
@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 #13
Source File: AllureCucumber3JvmTest.java From allure-java with Apache License 2.0 | 6 votes |
@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 #14
Source File: AllureStoryReporter.java From vividus with Apache License 2.0 | 6 votes |
public void addLogStep(String logLevel, String logEntry) { checkForBeforeAfterScenarioSteps(); String stepId = getCurrentStepId(); if (stepId != null) { StepResult log = new StepResult(); switch (logLevel) { case "DEBUG": log.setStatusDetails(new StatusDetails().setMuted(true)); break; case "ERROR": log.setStatus(Status.FAILED); break; default: log.setStatus(Status.PASSED); break; } log.setName(logEntry); String logUid = UUID.randomUUID().toString(); lifecycle.startStep(stepId, logUid, log); lifecycle.stopStep(logUid); } }
Example #15
Source File: StepLifecycleListenerTest.java From allure-java with Apache License 2.0 | 6 votes |
@Test void shouldExecuteBeforeStepStart() { final AtomicInteger executionCount = new AtomicInteger(); final StepLifecycleListener listener = new StepLifecycleListener() { @Override public void beforeStepStart(final StepResult result) { executionCount.incrementAndGet(); } }; final AllureResults run = run(listener, "first", "second"); assertThat(run.getTestResults()) .flatExtracting(TestResult::getSteps) .extracting(StepResult::getName) .containsExactly("first", "second"); assertThat(executionCount.get()) .isEqualTo(2); }
Example #16
Source File: AllureTestNgTest.java From allure-java with Apache License 2.0 | 6 votes |
@SuppressWarnings("unchecked") @AllureFeatures.Fixtures @Issue("304") @Test(dataProvider = "parallelConfiguration") public void shouldProcessFailedSetUps(final XmlSuite.ParallelMode mode, final int threadCount) { final AllureResults results = runTestNgSuites(parallel(mode, threadCount), "suites/gh-304.xml"); assertThat(results.getTestResults()) .extracting(TestResult::getName, TestResult::getStatus) .contains(tuple("skippedTest", Status.SKIPPED)); assertThat(results.getTestResultContainers()) .flatExtracting(TestResultContainer::getAfters) .extracting(FixtureResult::getName, FixtureResult::getStatus) .contains(tuple("afterAlways", Status.PASSED)); assertThat(results.getTestResultContainers()) .flatExtracting(TestResultContainer::getAfters) .filteredOn("name", "afterAlways") .flatExtracting(FixtureResult::getSteps) .extracting(StepResult::getName) .containsExactly( "first", "second" ); }
Example #17
Source File: Allure1StepsAspectsTest.java From allure-java with Apache License 2.0 | 6 votes |
@Test void shouldSetupStepTitleFromMethodSignature() { final AllureResults results = runWithinTestContext( () -> stepWithoutTitleAndWithParameter("parameter value"), Allure1StepsAspects::setLifecycle ); assertThat(results.getTestResults()) .flatExtracting(TestResult::getSteps) .extracting(StepResult::getName) .containsExactly("stepWithoutTitleAndWithParameter[parameter value]"); assertThat(results.getTestResults()) .flatExtracting(TestResult::getSteps) .flatExtracting(StepResult::getParameters) .extracting("name", "value") .containsExactly(tuple("parameter", "parameter value")); }
Example #18
Source File: AllureCucumber4Jvm.java From allure-java with Apache License 2.0 | 6 votes |
private void handleTestStepStarted(final TestStepStarted event) { if (event.testStep instanceof PickleStepTestStep) { final PickleStepTestStep pickleStep = (PickleStepTestStep) event.testStep; final String stepKeyword = Optional.ofNullable( testSources.getKeywordFromSource(currentFeatureFile.get(), pickleStep.getStepLine()) ).orElse("UNDEFINED"); final StepResult stepResult = new StepResult() .setName(String.format("%s %s", stepKeyword, pickleStep.getPickleStep().getText())) .setStart(System.currentTimeMillis()); lifecycle.startStep(getTestCaseUuid(currentTestCase.get()), getStepUuid(pickleStep), stepResult); pickleStep.getStepArgument().stream() .filter(PickleTable.class::isInstance) .findFirst() .ifPresent(table -> createDataTableAttachment((PickleTable) table)); } else if (event.testStep instanceof HookTestStep) { initHook((HookTestStep) event.testStep); } }
Example #19
Source File: AllureTestNgTest.java From allure-java with Apache License 2.0 | 6 votes |
@AllureFeatures.BrokenTests @Test(description = "Broken testng") public void brokenTest() { String testName = "brokenTest"; final AllureResults results = runTestNgSuites("suites/broken.xml"); List<TestResult> testResult = results.getTestResults(); assertThat(testResult).as("Test case result has not been written").hasSize(1); assertThat(testResult.get(0)).as("Unexpected broken testng property") .hasFieldOrPropertyWithValue("status", Status.BROKEN) .hasFieldOrPropertyWithValue("stage", Stage.FINISHED) .hasFieldOrPropertyWithValue("name", testName); assertThat(testResult.get(0).getStatusDetails()).as("Test Status Details") .hasFieldOrPropertyWithValue("message", "Exception") .hasFieldOrProperty("trace"); assertThat(testResult) .flatExtracting(TestResult::getSteps) .hasSize(2) .extracting(StepResult::getStatus) .contains(Status.PASSED, Status.BROKEN); }
Example #20
Source File: AllureCucumber4JvmTest.java From allure-java with Apache License 2.0 | 6 votes |
@AllureFeatures.Steps @Test void shouldAddBackgroundSteps() { final AllureResultsWriterStub writer = new AllureResultsWriterStub(); runFeature(writer, "features/background.feature"); final List<TestResult> testResults = writer.getTestResults(); assertThat(testResults) .hasSize(1) .flatExtracting(TestResult::getSteps) .extracting(StepResult::getName) .containsExactly( "Given cat is sad", "And cat is murmur", "When Pet the cat", "Then Cat is happy" ); }
Example #21
Source File: AllureJbehaveTest.java From allure-java with Apache License 2.0 | 6 votes |
@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 #22
Source File: AllureCucumber4JvmTest.java From allure-java with Apache License 2.0 | 6 votes |
@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 #23
Source File: AllureTestNgTest.java From allure-java with Apache License 2.0 | 6 votes |
@AllureFeatures.Base @Test(description = "Singe testng") public void singleTest() { final String testName = "testWithOneStep"; final AllureResults results = runTestNgSuites("suites/single-test.xml"); List<TestResult> testResult = results.getTestResults(); assertThat(testResult).as("Test case result has not been written").hasSize(1); assertThat(testResult.get(0)).as("Unexpected passed testng property") .hasFieldOrPropertyWithValue("status", Status.PASSED) .hasFieldOrPropertyWithValue("stage", Stage.FINISHED) .hasFieldOrPropertyWithValue("name", testName); assertThat(testResult) .flatExtracting(TestResult::getSteps) .hasSize(1) .extracting(StepResult::getStatus) .contains(Status.PASSED); }
Example #24
Source File: StepsAspectsTest.java From allure-java with Apache License 2.0 | 6 votes |
@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 #25
Source File: AllureAspectJTest.java From allure-java with Apache License 2.0 | 6 votes |
@AllureFeatures.Steps @Test void softAssertions() { final AllureResults results = runWithinTestContext(() -> { final SoftAssertions soft = new SoftAssertions(); soft.assertThat(25) .as("Test description") .isEqualTo(26); soft.assertAll(); }, AllureAspectJ::setLifecycle); assertThat(results.getTestResults()) .flatExtracting(TestResult::getSteps) .extracting(StepResult::getName) .contains("as 'Test description []'", "isEqualTo '26'"); }
Example #26
Source File: AllureSelenideTest.java From allure-java with Apache License 2.0 | 6 votes |
@AllureFeatures.Steps @Test void shouldLogPassedSteps() { final AllureResults results = runWithinTestContext(() -> { final AllureSelenide selenide = new AllureSelenide() .savePageSource(false) .screenshots(false); SelenideLogger.addListener(UUID.randomUUID().toString(), selenide); final SelenideLog log = SelenideLogger.beginStep( "dummy source", "dummyMethod()", "param1", "param2" ); SelenideLogger.commitStep(log, LogEvent.EventStatus.PASS); }); final StepResult selenideStep = extractStepFromResults(results); assertThat(selenideStep) .extracting(StepResult::getName, StepResult::getStatus) .containsExactly( "$(\"dummy source\") dummy method()([param1, param2])", Status.PASSED ); }
Example #27
Source File: AllureSelenideTest.java From allure-java with Apache License 2.0 | 6 votes |
@AllureFeatures.Steps @Test void shouldNotLogSelenideLocatorSteps() { final AllureResults results = runWithinTestContext(() -> { final AllureSelenide selenide = new AllureSelenide() .savePageSource(false) .screenshots(false) .includeSelenideSteps(false); SelenideLogger.addListener(UUID.randomUUID().toString(), selenide); Allure.step("step1"); final SelenideLog log = SelenideLogger.beginStep( "dummy source", "dummyMethod()" ); SelenideLogger.commitStep(log, LogEvent.EventStatus.PASS); Allure.step("step2"); }); List<StepResult> steps = extractAllStepsFromResults(results); assertThat(steps).hasSize(2); assertThat(steps.get(0).getName()).isEqualTo("step1"); // no selenide steps in between assertThat(steps.get(1).getName()).isEqualTo("step2"); }
Example #28
Source File: AllureSelenideTest.java From allure-java with Apache License 2.0 | 6 votes |
@AllureFeatures.Attachments @Test void shouldNotFailIfBrowserIsNotOpened() { final AllureResults results = runWithinTestContext(() -> { final AllureSelenide selenide = new AllureSelenide() .savePageSource(false) .screenshots(true); SelenideLogger.addListener(UUID.randomUUID().toString(), selenide); final SelenideLog log = SelenideLogger.beginStep( "open", "https://some.url" ); SelenideLogger.commitStep(log, new WebDriverException("failed to open a browser")); }); final StepResult selenideStep = extractStepFromResults(results); assertThat(selenideStep.getStatus()).isEqualTo(Status.BROKEN); assertThat(selenideStep.getStatusDetails().getMessage()).startsWith("failed to open a browser"); assertThat(selenideStep.getName()).isEqualTo("$(\"open\") https://some.url"); assertThat(selenideStep.getStage()).isEqualTo(Stage.FINISHED); assertThat(selenideStep.getAttachments()).hasSize(0); }
Example #29
Source File: Allure2Plugin.java From allure2 with Apache License 2.0 | 6 votes |
private Step convert(final Path source, final ResultsVisitor visitor, final StepResult step) { final Step result = new Step() .setName(step.getName()) .setStatus(convert(step.getStatus())) .setTime(convert(step.getStart(), step.getStop())) .setParameters(convert(step.getParameters(), this::convert)) .setAttachments(convert(step.getAttachments(), attachment -> convert(source, visitor, attachment))) .setSteps(convert(step.getSteps(), s -> convert(source, visitor, s))); Optional.of(step) .map(StepResult::getStatusDetails) .ifPresent(statusDetails -> { result.setStatusMessage(statusDetails.getMessage()); result.setStatusTrace(statusDetails.getTrace()); }); return result; }
Example #30
Source File: AllureCucumber3Jvm.java From allure-java with Apache License 2.0 | 6 votes |
private void handleTestStepStarted(final TestStepStarted event) { if (event.testStep instanceof PickleStepTestStep) { final PickleStepTestStep pickleStep = (PickleStepTestStep) event.testStep; final String stepKeyword = Optional.ofNullable( cucumberSourceUtils.getKeywordFromSource(currentFeatureFile, pickleStep.getStepLine()) ).orElse("UNDEFINED"); final StepResult stepResult = new StepResult() .setName(String.format("%s %s", stepKeyword, pickleStep.getPickleStep().getText())) .setStart(System.currentTimeMillis()); lifecycle.startStep(getTestCaseUuid(currentTestCase), getStepUuid(pickleStep), stepResult); pickleStep.getStepArgument().stream() .filter(PickleTable.class::isInstance) .findFirst() .ifPresent(table -> createDataTableAttachment((PickleTable) table)); } else if (event.testStep instanceof HookTestStep) { initHook((HookTestStep) event.testStep); } }