private List<TestOutcome> latestTestOutcomes() { return stepListener.getTestOutcomes(); }
public void stepIgnored() { if (aStepHasFailed()) { markCurrentStepAs(SKIPPED); currentStepDone(SKIPPED); } else { currentStepDone(IGNORED); } }
private void recordStep(ExecutedStepDescription description) { if (!latestTestOutcome().isPresent()) { return; } TestStep step = new TestStep(AnnotatedStepDescription.from(description).getName()); startNewGroupIfNested(); setDefaultResultFromAnnotations(step, description); currentStepStack.push(step); recordStepToCurrentTestOutcome(step); }
/** * A step within a test is called. * This step might be nested in another step, in which case the original step becomes a group of steps. * * @param description the description of the test that is about to be run */ public void stepStarted(final ExecutedStepDescription description) { pushStepMethodIn(description); recordStep(description); if (currentTestIsABrowserTest() && browserIsOpen()) { takeInitialScreenshot(); } }
private void take(final ScreenshotType screenshotType) { if (currentStepExists() && browserIsOpen()) { try { Optional<ScreenshotAndHtmlSource> screenshotAndHtmlSource = grabScreenshot(); if (screenshotAndHtmlSource.isPresent()) { takeScreenshotIfRequired(screenshotType, screenshotAndHtmlSource.get()); } removeDuplicatedInitalScreenshotsIfPresent(); } catch (ScreenshotException e) { LOGGER.warn("Failed to take screenshot", e); } } }
/** * A test has finished. * * @param outcome the result of the test that just finished. */ public void testFinished(final TestOutcome outcome) { if (getTestOutcomes().isEmpty()) { return; } recordTestDuration(); getCurrentTestOutcome().addIssues(storywideIssues); // TODO: Disable when run from an IDE getCurrentTestOutcome().addTags(storywideTags); if (StepEventBus.getEventBus().isDryRun() || getCurrentTestOutcome().getResult() == IGNORED) { testAndTopLevelStepsShouldBeIgnored(); } if (currentTestIsABrowserTest()) { getCurrentTestOutcome().setDriver(getDriverUsedInThisTest()); updateSessionIdIfKnown(); closeBrowsers.forTestSuite(testSuite).closeIfConfiguredForANew(SCENARIO); } currentStepStack.clear(); }
@SuppressWarnings("ThrowableResultOfMethodCallIgnored") public boolean aStepHasFailed() { return ((!getTestOutcomes().isEmpty()) && (getCurrentTestOutcome().getResult() == TestResult.FAILURE || getCurrentTestOutcome().getResult() == TestResult.ERROR)); }
public void castActor(String name) { if ((baseStepListener != null) && (baseStepListener.latestTestOutcome() != null)) { baseStepListener.latestTestOutcome().ifPresent( testOutcome -> testOutcome.castActor(name) ); } } }
public boolean aStepHasFailedInTheCurrentExample() { if (currentExample == 0) { return aStepHasFailed(); } return (aStepHasFailed() && (currentExample == lastFailingExample)); }
private void updateManualResultsFrom(List<Tag> scenarioTags) { getStepEventBus(currentFeaturePath()).testIsManual(); manualResultDefinedIn(scenarioTags).ifPresent( result -> { if (result == TestResult.FAILURE) { String failureMessage = failureMessageFrom(currentScenarioDefinition.getDescription()).orElse("Failed manual test"); getStepEventBus(currentFeaturePath()).getBaseStepListener() .latestTestOutcome().ifPresent( outcome -> outcome.setTestFailureMessage(failureMessage)); } getStepEventBus(currentFeaturePath()).getBaseStepListener().overrideResultTo(result); } ); }
public void exampleFinished() { if (newStepForEachExample()) { currentStepDone(null); } if (latestTestOutcome().isPresent()) { latestTestOutcome().get().moveToNextRow(); } closeBrowsers.forTestSuite(testSuite).closeIfConfiguredForANew(EXAMPLE); }
private boolean newStepForEachExample() { if (!latestTestOutcome().isPresent()) { return false; } return (getCurrentTestOutcome().getTestSource() != null) && (!getCurrentTestOutcome().getTestSource().equalsIgnoreCase("junit")); }
public boolean testSuiteHasStarted() { return getBaseStepListener().testSuiteRunning(); }
private boolean shouldTakeScreenshots() { return (currentStepExists() && browserIsOpen() && !StepEventBus.getEventBus().aStepInTheCurrentTestHasFailed() && !StepEventBus.getEventBus().isDryRun() && !StepEventBus.getEventBus().currentTestIsSuspended()); }
public void testSuiteStarted(final Story story) { testSuite = null; testedStory = story; suiteStarted = true; clearStorywideTagsAndIssues(); }
protected TestOutcome getCurrentTestOutcome() { return latestTestOutcome().orElse(unavailableTestOutcome()); }
public void testSuiteFinished() { closeDarkroom(); clearStorywideTagsAndIssues(); ThucydidesWebDriverSupport.clearStepLibraries(); if (this.currentTestIsABrowserTest()) { this.closeBrowsers.forTestSuite(this.testSuite).closeIfConfiguredForANew(RestartBrowserForEach.FEATURE); } suiteStarted = false; }
public BaseStepListener withOutputDirectory(File outputDirectory) { if (pages != null) { return new BaseStepListener(outputDirectory, pages); } else { return new BaseStepListener(outputDirectory); } } }
public void lastTestPassedAfterRetries(int remainingTries, List<String> failureMessages,TestFailureCause testfailureCause) { if (latestTestOutcome().isPresent()) { latestTestOutcome().get().recordStep( TestStep.forStepCalled("UNSTABLE TEST:\n" + failureHistoryFor(failureMessages)) .withResult(TestResult.IGNORED)); latestTestOutcome().get().addTag(TestTag.withName("Retries: " + (remainingTries - 1)). andType("unstable test")); latestTestOutcome().get().setFlakyTestFailureCause(testfailureCause); } }
public void addTagsToCurrentStory(List<TestTag> tags) { getBaseStepListener().addTagsToCurrentStory(tags); }