diff --git a/serenity-core/src/main/java/net/thucydides/core/steps/BaseStepListener.java b/serenity-core/src/main/java/net/thucydides/core/steps/BaseStepListener.java index f7716f0af..2dc3b2f23 100644 --- a/serenity-core/src/main/java/net/thucydides/core/steps/BaseStepListener.java +++ b/serenity-core/src/main/java/net/thucydides/core/steps/BaseStepListener.java @@ -914,8 +914,7 @@ public void stepFailed(StepFailure failure) { currentStepDone(failureAnalysis.resultFor(failure)); } - - public void stepFailed(StepFailure failure, List screenshotList) { + public void stepFailed(StepFailure failure, List screenshotList, boolean isInDataDrivenTest) { if (!aStepHasFailed()) { // This is the actual failure, so record all the details @@ -925,10 +924,15 @@ public void stepFailed(StepFailure failure, List screen getCurrentTestOutcome().appendTestFailure(failureCause); recordFailureDetails(failure); + // Step marked as done with the appropriate result before + if (isInDataDrivenTest) { + currentStepDone(failureAnalysis.resultFor(failure)); + } + } + if (!isInDataDrivenTest) { // Step marked as done with the appropriate result before currentStepDone(failureAnalysis.resultFor(failure)); } - } diff --git a/serenity-core/src/main/java/net/thucydides/core/steps/StepEventBus.java b/serenity-core/src/main/java/net/thucydides/core/steps/StepEventBus.java index 3a8955248..6ffd3bd61 100644 --- a/serenity-core/src/main/java/net/thucydides/core/steps/StepEventBus.java +++ b/serenity-core/src/main/java/net/thucydides/core/steps/StepEventBus.java @@ -621,13 +621,14 @@ public void stepFailed(final StepFailure failure) { stepFailed = true; } - public void stepFailed(final StepFailure failure, List screenshotList) { + + public void stepFailed(final StepFailure failure, List screenshotList, boolean isInDataDrivenTest) { stepDone(); getResultTally().logFailure(failure); for (StepListener stepListener : getAllListeners()) { - stepListener.stepFailed(failure,screenshotList); + stepListener.stepFailed(failure,screenshotList,isInDataDrivenTest); } stepFailed = true; } diff --git a/serenity-core/src/main/java/net/thucydides/core/steps/StepInterceptor.java b/serenity-core/src/main/java/net/thucydides/core/steps/StepInterceptor.java index 52787c552..9c4e7479a 100644 --- a/serenity-core/src/main/java/net/thucydides/core/steps/StepInterceptor.java +++ b/serenity-core/src/main/java/net/thucydides/core/steps/StepInterceptor.java @@ -603,7 +603,7 @@ private void notifyOfStepFailure(final Object object, final Method method, final if (TestSession.isSessionStarted()) { List screenshotList = TestSession.getTestSessionContext().getStepEventBus().takeScreenshots(TestResult.FAILURE); - StepFailedEvent stepFailedEvent = new StepFailedEvent(failure,screenshotList); + StepFailedEvent stepFailedEvent = new StepFailedEvent(failure,screenshotList,TestSession.getTestSessionContext().isInDataDrivenTest()); TestSession.addEvent(stepFailedEvent); } else { diff --git a/serenity-core/src/main/java/net/thucydides/core/steps/events/StepFailedEvent.java b/serenity-core/src/main/java/net/thucydides/core/steps/events/StepFailedEvent.java index 53cf32643..7496666b5 100644 --- a/serenity-core/src/main/java/net/thucydides/core/steps/events/StepFailedEvent.java +++ b/serenity-core/src/main/java/net/thucydides/core/steps/events/StepFailedEvent.java @@ -1,5 +1,6 @@ package net.thucydides.core.steps.events; +import net.thucydides.core.steps.session.TestSession; import net.thucydides.model.screenshots.ScreenshotAndHtmlSource; import net.thucydides.model.steps.StepFailure; import org.slf4j.Logger; @@ -16,10 +17,20 @@ public class StepFailedEvent private final List screenshotList; + private boolean isInDataDrivenTest; public StepFailedEvent(StepFailure stepFailure, List screenshotList) { this.stepFailure = stepFailure; this.screenshotList = screenshotList; + if (TestSession.isSessionStarted()) { + this.isInDataDrivenTest = TestSession.getTestSessionContext().isInDataDrivenTest(); + } + } + + public StepFailedEvent(StepFailure stepFailure, List screenshotList, boolean isInDataDrivenTest) { + this.stepFailure = stepFailure; + this.screenshotList = screenshotList; + this.isInDataDrivenTest = isInDataDrivenTest; } @@ -27,7 +38,7 @@ public StepFailedEvent(StepFailure stepFailure, List sc public void play() { LOGGER.debug("SRP:PlayStepFinishedEvent with screenshot size " + ((screenshotList != null) ? screenshotList.size() : 0)); - getStepEventBus().stepFailed(stepFailure, screenshotList); + getStepEventBus().stepFailed(stepFailure, screenshotList, isInDataDrivenTest); } public String toString() { diff --git a/serenity-core/src/main/java/net/thucydides/core/steps/session/TestSessionContext.java b/serenity-core/src/main/java/net/thucydides/core/steps/session/TestSessionContext.java index 65a52ecb8..f423fdeef 100644 --- a/serenity-core/src/main/java/net/thucydides/core/steps/session/TestSessionContext.java +++ b/serenity-core/src/main/java/net/thucydides/core/steps/session/TestSessionContext.java @@ -18,10 +18,11 @@ public class TestSessionContext { private String currentTestName; + private boolean isInDataDrivenTest = false; - private AtomicBoolean sessionStarted = new AtomicBoolean(false); + private final AtomicBoolean sessionStarted = new AtomicBoolean(false); - private List stepEventBusEvents = Collections.synchronizedList(new LinkedList<>()); + private final List stepEventBusEvents = Collections.synchronizedList(new LinkedList<>()); public AtomicBoolean getSessionStarted() { return sessionStarted; @@ -90,4 +91,12 @@ public WebDriver getWebDriver() { public void setWebDriver(WebDriver webDriver) { this.webDriver = webDriver; } + + public boolean isInDataDrivenTest() { + return isInDataDrivenTest; + } + + public void setInDataDrivenTest(boolean inDataDrivenTest) { + isInDataDrivenTest = inDataDrivenTest; + } } diff --git a/serenity-core/src/test/java/net/thucydides/core/ListenerInWrongPackage.java b/serenity-core/src/test/java/net/thucydides/core/ListenerInWrongPackage.java index 0a52d6865..0fe962a74 100644 --- a/serenity-core/src/test/java/net/thucydides/core/ListenerInWrongPackage.java +++ b/serenity-core/src/test/java/net/thucydides/core/ListenerInWrongPackage.java @@ -1,129 +1,12 @@ package net.thucydides.core; -import net.thucydides.model.domain.DataTable; -import net.thucydides.model.domain.Story; import net.thucydides.model.domain.TestOutcome; -import net.thucydides.model.domain.TestResult; -import net.thucydides.model.screenshots.ScreenshotAndHtmlSource; -import net.thucydides.model.steps.ExecutedStepDescription; -import net.thucydides.model.steps.StepFailure; -import net.thucydides.model.steps.StepListener; +import net.thucydides.model.steps.StepListenerAdapter; import org.openqa.selenium.WebDriver; -import java.time.ZonedDateTime; import java.util.List; -import java.util.Map; -public class ListenerInWrongPackage implements StepListener { - public void testSuiteStarted(Class storyClass) { - - } - - public void testSuiteStarted(Story story) { - - } - - public void testSuiteFinished() { - } - - public void testStarted(String description) { - - } - - @Override - public void testStarted(String description, String id) { - - } - - @Override - public void testStarted(String description, String id, ZonedDateTime startTime) { - - } - - public void testFinished(TestOutcome result) { - - } - - @Override - public void testFinished(TestOutcome result, boolean isInDataDrivenTest, ZonedDateTime finishTime) { - - } - - public void testRetried() { - } - - public void stepStarted(ExecutedStepDescription description) { - - } - - public void skippedStepStarted(ExecutedStepDescription description) { - } - - public void stepFailed(StepFailure failure) { - - } - - @Override - public void stepFailed(StepFailure failure, List screenshotList) { - - } - - public void lastStepFailed(StepFailure failure) { - } - - public void stepIgnored() { - - } - - public void stepIgnored(String message) { - } - - public void stepPending() { - - } - - public void stepPending(String message) { - } - - public void stepFinished() { - - } - - @Override - public void stepFinished(List screenshotList) { - - } - - @Override - public void stepFinished(List screenshotList, ZonedDateTime time) { - - } - - public void testFailed(TestOutcome testOutcome, Throwable cause) { - } - - public void testIgnored() { - } - - @Override - public void testSkipped() { - - } - - @Override - public void testAborted() { - - } - - @Override - public void testPending() { - - } - - @Override - public void testIsManual() { - - } +public class ListenerInWrongPackage extends StepListenerAdapter { public List getTestOutcomes() { return null; @@ -132,44 +15,4 @@ public List getTestOutcomes() { public WebDriver getDriver() { return null; } - - public void notifyScreenChange() { - } - - public void useExamplesFrom(DataTable table) { - //To change body of implemented methods use File | Settings | File Templates. - } - - @Override - public void addNewExamplesFrom(DataTable table) { - - } - - public void exampleStarted(Map data) { - //To change body of implemented methods use File | Settings | File Templates. - } - - public void exampleFinished() { - //To change body of implemented methods use File | Settings | File Templates. - } - - @Override - public void assumptionViolated(String message) { - //To change body of implemented methods use File | Settings | File Templates. - } - - @Override - public void testRunFinished() { - - } - - @Override - public void takeScreenshots(List screenshots) { - - } - - @Override - public void takeScreenshots(TestResult testResult, List screenshots) { - - } } diff --git a/serenity-core/src/test/java/sample/listeners/SampleStepListener.java b/serenity-core/src/test/java/sample/listeners/SampleStepListener.java index fae330cb8..69e6c556f 100644 --- a/serenity-core/src/test/java/sample/listeners/SampleStepListener.java +++ b/serenity-core/src/test/java/sample/listeners/SampleStepListener.java @@ -1,129 +1,13 @@ package sample.listeners; -import net.thucydides.model.domain.DataTable; -import net.thucydides.model.domain.Story; import net.thucydides.model.domain.TestOutcome; -import net.thucydides.model.domain.TestResult; -import net.thucydides.model.screenshots.ScreenshotAndHtmlSource; -import net.thucydides.model.steps.ExecutedStepDescription; -import net.thucydides.model.steps.StepFailure; -import net.thucydides.model.steps.StepListener; +import net.thucydides.model.steps.StepListenerAdapter; import org.openqa.selenium.WebDriver; -import java.time.ZonedDateTime; import java.util.List; -import java.util.Map; -public class SampleStepListener implements StepListener { - public void testSuiteStarted(Class storyClass) { - - } - - public void testSuiteStarted(Story story) { - - } - - public void testSuiteFinished() { - } - - public void testStarted(String description) { - - } - - @Override - public void testStarted(String description, String id) { - - } - - @Override - public void testStarted(String description, String id, ZonedDateTime startTime) { - - } - - public void testFinished(TestOutcome result) { - - } - - @Override - public void testFinished(TestOutcome result, boolean isInDataDrivenTest, ZonedDateTime finishTime) { - - } - - public void testRetried() { - } - - public void stepStarted(ExecutedStepDescription description) { - - } - - public void skippedStepStarted(ExecutedStepDescription description) { - } - - public void stepFailed(StepFailure failure) { - - } - - @Override - public void stepFailed(StepFailure failure, List screenshotList) { - - } - - public void lastStepFailed(StepFailure failure) { - } - - public void stepIgnored() { - - } - - public void stepIgnored(String message) { - } - - public void stepPending() { - - } - - public void stepPending(String message) { - } - - public void stepFinished() { - - } - - @Override - public void stepFinished(List screenshotList) { +public class SampleStepListener extends StepListenerAdapter { - } - - @Override - public void stepFinished(List screenshotList, ZonedDateTime time) { - - } - - public void testFailed(TestOutcome testOutcome, Throwable cause) { - } - - public void testIgnored() { - } - - @Override - public void testSkipped() { - - } - - @Override - public void testAborted() { - - } - - @Override - public void testPending() { - - } - - @Override - public void testIsManual() { - - } public List getTestOutcomes() { return null; @@ -132,43 +16,4 @@ public List getTestOutcomes() { public WebDriver getDriver() { return null; } - - public void notifyScreenChange() { - } - - public void useExamplesFrom(DataTable table) { - } - - @Override - public void addNewExamplesFrom(DataTable table) { - - } - - public void exampleStarted(Map data) { - //To change body of implemented methods use File | Settings | File Templates. - } - - public void exampleFinished() { - //To change body of implemented methods use File | Settings | File Templates. - } - - @Override - public void assumptionViolated(String message) { - //To change body of implemented methods use File | Settings | File Templates. - } - - @Override - public void testRunFinished() { - - } - - @Override - public void takeScreenshots(List screenshots) { - - } - - @Override - public void takeScreenshots(TestResult testResult, List screenshots) { - - } } diff --git a/serenity-cucumber/src/main/java/io/cucumber/core/plugin/SerenityReporterParallel.java b/serenity-cucumber/src/main/java/io/cucumber/core/plugin/SerenityReporterParallel.java index 79fa72fa7..9b0410003 100644 --- a/serenity-cucumber/src/main/java/io/cucumber/core/plugin/SerenityReporterParallel.java +++ b/serenity-cucumber/src/main/java/io/cucumber/core/plugin/SerenityReporterParallel.java @@ -273,6 +273,7 @@ private void handleTestCaseStarted(TestCaseStarted event) { if (newScenario) { configureDriver(currentFeature.get(), event.getTestCase().getUri()); if (!currentScenarioDefinition.getExamples().isEmpty()) { + TestSession.getTestSessionContext().setInDataDrivenTest(true); context.startNewExample(scenarioId); LOGGER.debug("SRP:startNewExample {} {} {} at line {} ", event.getTestCase().getUri(), Thread.currentThread(), event.getTestCase().getId(), event.getTestCase().getLocation().getLine()); @@ -352,7 +353,7 @@ private void handleTestCaseFinished(TestCaseFinished event) { String scenarioId = scenarioIdFrom(currentFeature.get().getName(), TestSourcesModel.convertToId(currentScenarioDefinition.getName())); if (getContext(featurePath).examplesAreRunning(scenarioId)) { - handleResult(scenarioId, featurePath, event.getTestCase(), event.getResult()); + handleResult(scenarioId, featurePath, event.getTestCase(), event.getResult(), true); finishProcessingExampleLine(scenarioId, featurePath, event.getTestCase()); } @@ -506,7 +507,7 @@ private void handleTestStepFinished(TestStepFinished event) { if ((astNode != null) && currentFeature.isPresent()) { Scenario currentScenarioDefinition = TestSourcesModel.getScenarioDefinition(astNode); scenarioId = scenarioIdFrom(currentFeature.get().getName(), TestSourcesModel.convertToId(currentScenarioDefinition.getName())); - handleResult(scenarioId, event.getTestCase().getUri(), event.getTestCase(), event.getResult()); + handleResult(scenarioId, event.getTestCase().getUri(), event.getTestCase(), event.getResult(), false); } StepDefinitionAnnotations.clear(); } @@ -1005,19 +1006,19 @@ private void cleanupTestResourcesForURI(URI uri) { StepEventBus.clearEventBusFor(uri); } - private void handleResult(String scenarioId, URI featurePath, TestCase testCase, Result result) { + private void handleResult(String scenarioId, URI featurePath, TestCase testCase, Result result, boolean isInDataDrivenTest) { io.cucumber.messages.types.Step currentStep = getContext(featurePath).nextStep(testCase); TestStep currentTestStep = getContext(featurePath).nextTestStep(testCase); - recordStepResult(featurePath, testCase, result, currentStep, currentTestStep); + recordStepResult(featurePath, result, currentStep, currentTestStep, isInDataDrivenTest); if (getContext(featurePath).noStepsAreQueued(testCase)) { recordFinalResult(scenarioId, featurePath, testCase); } } - private void recordStepResult(URI featurePath, TestCase testCase, Result result, io.cucumber.messages.types.Step currentStep, TestStep currentTestStep) { + private void recordStepResult(URI featurePath, Result result, io.cucumber.messages.types.Step currentStep, TestStep currentTestStep, boolean isInDataDrivenTest) { ZonedDateTime endTime = ZonedDateTime.now(); List screenshotList = getContext(featurePath).stepEventBus().takeScreenshots(); - getContext(featurePath).addStepEventBusEvent(new StepFinishedWithResultEvent(result, currentStep, currentTestStep, screenshotList, endTime)); + getContext(featurePath).addStepEventBusEvent(new StepFinishedWithResultEvent(result, currentStep, currentTestStep, screenshotList, endTime, isInDataDrivenTest)); } private void recordFinalResult(String scenarioId, URI featurePath, TestCase testCase) { diff --git a/serenity-cucumber/src/main/java/net/serenitybdd/cucumber/events/StepFinishedWithResultEvent.java b/serenity-cucumber/src/main/java/net/serenitybdd/cucumber/events/StepFinishedWithResultEvent.java index 642be64ec..9466b7099 100644 --- a/serenity-cucumber/src/main/java/net/serenitybdd/cucumber/events/StepFinishedWithResultEvent.java +++ b/serenity-cucumber/src/main/java/net/serenitybdd/cucumber/events/StepFinishedWithResultEvent.java @@ -24,18 +24,21 @@ public class StepFinishedWithResultEvent extends StepEventBusEventBase { private final Result result; private final io.cucumber.messages.types.Step currentStep; private final TestStep currentTestStep; - private final List screenshotList; + boolean isInDataDrivenTest; + public StepFinishedWithResultEvent(Result result, io.cucumber.messages.types.Step currentStep, TestStep currentTestStep, List screenshotList, - ZonedDateTime time){ + ZonedDateTime time, + boolean isInDataDrivenTest) { this.result = result; this.currentStep = currentStep; this.currentTestStep = currentTestStep; this.screenshotList = screenshotList; this.timestamp = time; + this.isInDataDrivenTest = isInDataDrivenTest; } @Override @@ -65,7 +68,8 @@ private void failed(String stepTitle, Throwable cause, List resultTally = new TestResultTally<>(); private final Set testSuiteIssues = new CopyOnWriteArraySet<>(); @@ -52,18 +48,6 @@ public void testSuiteStarted(final Story story) { testSuiteIssues.clear(); } - public void testStarted(final String testName) { - } - - @Override - public void testStarted(String description, String id) { - - } - - @Override - public void testStarted(String description, String id, ZonedDateTime startTime) { - - } @Override public void testFinished(TestOutcome result) { @@ -98,82 +82,6 @@ public void testSuiteFinished() { } } - public void testRetried() {} - - public void stepStarted(ExecutedStepDescription executedStepDescription) {} - - public void skippedStepStarted(ExecutedStepDescription description) {} - - public void stepFailed(StepFailure stepFailure) {} - - @Override - public void stepFailed(StepFailure failure, List screenshotList) { - - } - - public void lastStepFailed(StepFailure stepFailure) {} - - public void stepIgnored() {} - - public void stepIgnored(String s) {} - - public void stepPending() {} - - public void stepPending(String s) {} - - public void assumptionViolated(String s) {} - - public void testRunFinished() { - } - - @Override - public void takeScreenshots(List screenshots) { - - } - - @Override - public void takeScreenshots(TestResult testResult, List screenshots) { - - } - - public void stepFinished() {} - - @Override - public void stepFinished(List screenshotList) { - - } - - @Override - public void stepFinished(List screenshotList, ZonedDateTime time) { - - } - - public void testFailed(TestOutcome testOutcome, Throwable cause) {} - - public void testIgnored() {} - - @Override - public void testSkipped() {} - - @Override - public void testPending() {} - - @Override - public void testIsManual() {} - - public void notifyScreenChange() {} - - public void useExamplesFrom(DataTable dataTable) {} - - @Override - public void addNewExamplesFrom(DataTable dataTable) {} - - public void exampleStarted(Map stringStringMap) {} - - public void exampleStarted() {} - - public void exampleFinished() {} - public TestResultTally getTestResultTally(){ return resultTally; } diff --git a/serenity-junit/src/main/java/net/serenitybdd/junit/runners/FailureDetectingStepListener.java b/serenity-junit/src/main/java/net/serenitybdd/junit/runners/FailureDetectingStepListener.java index 623b195fc..6e6ec6d03 100644 --- a/serenity-junit/src/main/java/net/serenitybdd/junit/runners/FailureDetectingStepListener.java +++ b/serenity-junit/src/main/java/net/serenitybdd/junit/runners/FailureDetectingStepListener.java @@ -1,22 +1,13 @@ package net.serenitybdd.junit.runners; import net.serenitybdd.model.collect.NewList; -import net.thucydides.model.domain.DataTable; -import net.thucydides.model.domain.Story; import net.thucydides.model.domain.TestOutcome; -import net.thucydides.model.domain.TestResult; -import net.thucydides.model.screenshots.ScreenshotAndHtmlSource; -import net.thucydides.model.steps.ExecutedStepDescription; -import net.thucydides.model.steps.StepFailure; -import net.thucydides.model.steps.StepListener; -import net.thucydides.model.steps.TestFailureCause; +import net.thucydides.model.steps.*; -import java.time.ZonedDateTime; import java.util.ArrayList; import java.util.List; -import java.util.Map; -public class FailureDetectingStepListener implements StepListener { +public class FailureDetectingStepListener extends StepListenerAdapter { private boolean lastTestFailed = false; private final List failureMessages = new ArrayList<>(); @@ -38,25 +29,6 @@ public void testFailed(TestOutcome testOutcome, Throwable cause) { testFailureCause = TestFailureCause.from(cause); } - public void lastStepFailed(StepFailure failure) { - - } - - public void testSuiteStarted(Class storyClass) { - - } - - - public void testSuiteStarted(Story storyOrFeature) { - - } - - - public void testSuiteFinished() { - - } - - public void testStarted(String description) { lastTestFailed = false; } @@ -66,140 +38,6 @@ public void testStarted(String description, String id) { lastTestFailed = false; } - @Override - public void testStarted(String description, String id, ZonedDateTime startTime) { - - } - - - public void testFinished(TestOutcome result) { - - } - - @Override - public void testFinished(TestOutcome result, boolean isInDataDrivenTest, ZonedDateTime finishTime) { - - } - - - public void testRetried() { - - } - - - public void stepStarted(ExecutedStepDescription description) { - - } - - - public void skippedStepStarted(ExecutedStepDescription description) { - - } - - - public void stepFailed(StepFailure failure) { - - } - - @Override - public void stepFailed(StepFailure failure, List screenshotList) { - - } - - - public void stepIgnored() { - - } - - - public void stepPending() { - - } - - - public void stepPending(String message) { - - } - - - public void stepFinished() { - - } - - @Override - public void stepFinished(List screenshotList) { - - } - - @Override - public void stepFinished(List screenshotList, ZonedDateTime time) { - - } - - - public void testIgnored() { - - } - - @Override - public void testSkipped() { - - } - - @Override - public void testPending() { - - } - - @Override - public void testIsManual() { - - } - - - public void notifyScreenChange() { - - } - - - public void useExamplesFrom(DataTable table) { - - } - - @Override - public void addNewExamplesFrom(DataTable table) { - - } - - - public void exampleStarted(Map data) { - - } - - - public void exampleFinished() { - - } - - - public void assumptionViolated(String message) { - - } - - @Override - public void testRunFinished() { - - } - - @Override - public void takeScreenshots(List screenshots) { - - } - - @Override - public void takeScreenshots(TestResult testResult, List screenshots) { - - } public TestFailureCause getTestFailureCause(){ return testFailureCause; diff --git a/serenity-junit/src/main/java/net/thucydides/junit/listeners/TestCountListener.java b/serenity-junit/src/main/java/net/thucydides/junit/listeners/TestCountListener.java index 149c03bd3..2c5684b62 100644 --- a/serenity-junit/src/main/java/net/thucydides/junit/listeners/TestCountListener.java +++ b/serenity-junit/src/main/java/net/thucydides/junit/listeners/TestCountListener.java @@ -1,26 +1,15 @@ package net.thucydides.junit.listeners; import net.thucydides.model.logging.LoggingLevel; -import net.thucydides.model.domain.DataTable; -import net.thucydides.model.domain.Story; -import net.thucydides.model.domain.TestOutcome; -import net.thucydides.model.domain.TestResult; -import net.thucydides.model.screenshots.ScreenshotAndHtmlSource; import net.thucydides.model.statistics.TestCount; -import net.thucydides.model.steps.ExecutedStepDescription; -import net.thucydides.model.steps.StepFailure; -import net.thucydides.model.steps.StepListener; +import net.thucydides.model.steps.StepListenerAdapter; import net.thucydides.model.util.EnvironmentVariables; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.time.ZonedDateTime; -import java.util.List; -import java.util.Map; - import static net.thucydides.model.ThucydidesSystemProperty.SERENITY_DISPLAY_TEST_NUMBERS; -public class TestCountListener implements StepListener { +public class TestCountListener extends StepListenerAdapter { private final Logger logger; private final EnvironmentVariables environmentVariables; @@ -42,17 +31,6 @@ protected Logger getLogger() { return logger; } - public void testSuiteStarted(Class storyClass) { - } - - - public void testSuiteStarted(Story storyOrFeature) { - } - - - public void testSuiteFinished() { - } - public void testStarted(String description) { int currentTestCount = testCount.getNextTest(); @@ -66,130 +44,4 @@ public void testStarted(String description, String id) { testStarted(description); } - @Override - public void testStarted(String description, String id, ZonedDateTime startTime) { - - } - - - public void testFinished(TestOutcome result) { - } - - @Override - public void testFinished(TestOutcome result, boolean isInDataDrivenTest, ZonedDateTime finishTime) { - - } - - public void testRetried() { - } - - public void stepStarted(ExecutedStepDescription description) { - } - - - public void skippedStepStarted(ExecutedStepDescription description) { - } - - - public void stepFailed(StepFailure failure) { - } - - @Override - public void stepFailed(StepFailure failure, List screenshotList) { - - } - - - public void lastStepFailed(StepFailure failure) { - } - - - public void stepIgnored() { - } - - public void stepPending() { - } - - - public void stepPending(String message) { - } - - - public void stepFinished() { - } - - @Override - public void stepFinished(List screenshotList) { - - } - - @Override - public void stepFinished(List screenshotList, ZonedDateTime time) { - - } - - - public void testFailed(TestOutcome testOutcome, Throwable cause) { - } - - - public void testIgnored() { - } - - @Override - public void testSkipped() { - - } - - @Override - public void testAborted() { - - } - - @Override - public void testPending() { - - } - - @Override - public void testIsManual() { - - } - - - public void notifyScreenChange() { - } - - public void useExamplesFrom(DataTable table) { - } - - @Override - public void addNewExamplesFrom(DataTable table) { - - } - - public void exampleStarted(Map data) { - } - - public void exampleFinished() { - } - - @Override - public void assumptionViolated(String message) { - } - - @Override - public void testRunFinished() { - - } - - @Override - public void takeScreenshots(List screenshots) { - - } - - @Override - public void takeScreenshots(TestResult testResult, List screenshots) { - - } } diff --git a/serenity-model/src/main/java/net/thucydides/model/logging/ConsoleLoggingListener.java b/serenity-model/src/main/java/net/thucydides/model/logging/ConsoleLoggingListener.java index 7f0824c06..3821a181c 100644 --- a/serenity-model/src/main/java/net/thucydides/model/logging/ConsoleLoggingListener.java +++ b/serenity-model/src/main/java/net/thucydides/model/logging/ConsoleLoggingListener.java @@ -3,7 +3,6 @@ import net.serenitybdd.model.collect.NewList; import net.serenitybdd.model.strings.Joiner; -import net.thucydides.model.domain.DataTable; import net.thucydides.model.domain.Story; import net.thucydides.model.domain.TestOutcome; import net.thucydides.model.domain.TestResult; @@ -11,7 +10,7 @@ import net.thucydides.model.screenshots.ScreenshotAndHtmlSource; import net.thucydides.model.steps.ExecutedStepDescription; import net.thucydides.model.steps.StepFailure; -import net.thucydides.model.steps.StepListener; +import net.thucydides.model.steps.StepListenerAdapter; import net.thucydides.model.util.EnvironmentVariables; import net.thucydides.model.util.NameConverter; import org.apache.commons.lang3.StringUtils; @@ -25,7 +24,7 @@ import static net.thucydides.model.logging.ConsoleEvent.*; -public class ConsoleLoggingListener implements StepListener { +public class ConsoleLoggingListener extends StepListenerAdapter { public static final String SERENITY_BIG_BANNER = "\n\n-------------------------------------------------------------------------------------\n" + @@ -127,10 +126,6 @@ public void testSuiteStarted(Story story) { } } - - public void testSuiteFinished() { - } - public void testStarted(String description) { flaggedSteps.clear(); reportedOutcomes.clear(); @@ -199,9 +194,6 @@ public void testFinished(final TestOutcome result, boolean isInDataDrivenTest, Z } - @Override - public void testRetried() { - } private Map> coloredLogs() { Map> coloredLogs = new HashMap<>(); @@ -342,7 +334,7 @@ public void stepFailed(StepFailure failure) { } @Override - public void stepFailed(StepFailure failure, List screenshotList) { + public void stepFailed(StepFailure failure, List screenshotList, boolean isInDataDrivenTest) { if (loggingLevelIsAtLeast(LoggingLevel.VERBOSE)) { stepFailed(failure); } @@ -357,10 +349,6 @@ private synchronized void stepOut() { } - public void lastStepFailed(StepFailure failure) { - } - - public void stepIgnored() { stepOut(); if (loggingLevelIsAtLeast(LoggingLevel.VERBOSE) && (!flaggedSteps.contains(currentStep))) { @@ -387,10 +375,6 @@ public void stepPending(String message) { } - public void testFailed(TestOutcome testOutcome, Throwable cause) { - } - - public void testIgnored() { if (loggingLevelIsAtLeast(LoggingLevel.NORMAL)) { getLogger().info(colored.yellow(" -> TEST IGNORED")); @@ -411,32 +395,6 @@ public void testAborted() { } } - @Override - public void testPending() { - } - - @Override - public void testIsManual() { - } - - - public void notifyScreenChange() { - } - - public void useExamplesFrom(DataTable table) { - } - - @Override - public void addNewExamplesFrom(DataTable table) { - - } - - public void exampleStarted(Map data) { - } - - public void exampleFinished() { - } - @Override public void assumptionViolated(String message) { if (loggingLevelIsAtLeast(LoggingLevel.QUIET)) { @@ -450,15 +408,4 @@ public void testRunFinished() { getLogger().info("FINISHING TEST RUN"); } } - - @Override - public void takeScreenshots(List screenshots) { - - } - - @Override - public void takeScreenshots(TestResult testResult, List screenshots) { - - } - } diff --git a/serenity-model/src/main/java/net/thucydides/model/steps/StepListener.java b/serenity-model/src/main/java/net/thucydides/model/steps/StepListener.java index cd1f27324..fc4a195fd 100644 --- a/serenity-model/src/main/java/net/thucydides/model/steps/StepListener.java +++ b/serenity-model/src/main/java/net/thucydides/model/steps/StepListener.java @@ -106,9 +106,10 @@ default void stepStarted(final ExecutedStepDescription description, ZonedDateTim * Called when a test step fails. * * @param failure describes the test that failed and the exception that was thrown + * @param screenshotList list of screenshots + * @param isInDataDrivenTest if the step failed was called from a data driven test */ - void stepFailed(final StepFailure failure, List screenshotList); - + void stepFailed(final StepFailure failure, List screenshotList, boolean isInDataDrivenTest); /** * Declare that a step has failed after it has finished. diff --git a/serenity-model/src/main/java/net/thucydides/model/steps/StepListenerAdapter.java b/serenity-model/src/main/java/net/thucydides/model/steps/StepListenerAdapter.java new file mode 100644 index 000000000..624b5eb29 --- /dev/null +++ b/serenity-model/src/main/java/net/thucydides/model/steps/StepListenerAdapter.java @@ -0,0 +1,178 @@ +package net.thucydides.model.steps; + +import net.thucydides.model.domain.DataTable; +import net.thucydides.model.domain.Story; +import net.thucydides.model.domain.TestOutcome; +import net.thucydides.model.domain.TestResult; +import net.thucydides.model.screenshots.ScreenshotAndHtmlSource; + +import java.time.ZonedDateTime; +import java.util.List; +import java.util.Map; + +public class StepListenerAdapter implements StepListener { + @Override + public void testSuiteStarted(Class storyClass) { + + } + + @Override + public void testSuiteStarted(Story story) { + + } + + @Override + public void testSuiteFinished() { + + } + + @Override + public void testStarted(String description) { + + } + + @Override + public void testStarted(String description, String id) { + + } + + @Override + public void testStarted(String description, String id, ZonedDateTime startTime) { + + } + + @Override + public void testFinished(TestOutcome result) { + + } + + @Override + public void testFinished(TestOutcome result, boolean isInDataDrivenTest, ZonedDateTime finishTime) { + + } + + @Override + public void testRetried() { + + } + + @Override + public void stepStarted(ExecutedStepDescription description) { + + } + + @Override + public void skippedStepStarted(ExecutedStepDescription description) { + + } + + @Override + public void stepFailed(StepFailure failure) { + + } + + @Override + public void stepFailed(StepFailure failure, List screenshotList, boolean isInDataDrivenTest) { + + } + + @Override + public void lastStepFailed(StepFailure failure) { + + } + + @Override + public void stepIgnored() { + + } + + @Override + public void stepPending() { + + } + + @Override + public void stepPending(String message) { + + } + + @Override + public void stepFinished() { + + } + + @Override + public void stepFinished(List screenshotList, ZonedDateTime time) { + + } + + @Override + public void testFailed(TestOutcome testOutcome, Throwable cause) { + + } + + @Override + public void testIgnored() { + + } + + @Override + public void testSkipped() { + + } + + @Override + public void testPending() { + + } + + @Override + public void testIsManual() { + + } + + @Override + public void notifyScreenChange() { + + } + + @Override + public void useExamplesFrom(DataTable table) { + + } + + @Override + public void addNewExamplesFrom(DataTable table) { + + } + + @Override + public void exampleStarted(Map data) { + + } + + @Override + public void exampleFinished() { + + } + + @Override + public void assumptionViolated(String message) { + + } + + @Override + public void testRunFinished() { + + } + + @Override + public void takeScreenshots(List screenshots) { + + } + + @Override + public void takeScreenshots(TestResult testResult, List screenshots) { + + } +} diff --git a/serenity-rest-assured/src/main/java/net/serenitybdd/rest/RestStepListener.java b/serenity-rest-assured/src/main/java/net/serenitybdd/rest/RestStepListener.java index 99315be7c..8d1787cd0 100644 --- a/serenity-rest-assured/src/main/java/net/serenitybdd/rest/RestStepListener.java +++ b/serenity-rest-assured/src/main/java/net/serenitybdd/rest/RestStepListener.java @@ -1,186 +1,7 @@ package net.serenitybdd.rest; -import net.thucydides.model.domain.DataTable; -import net.thucydides.model.domain.Story; -import net.thucydides.model.domain.TestOutcome; -import net.thucydides.model.domain.TestResult; -import net.thucydides.model.screenshots.ScreenshotAndHtmlSource; -import net.thucydides.model.steps.ExecutedStepDescription; -import net.thucydides.model.steps.StepFailure; -import net.thucydides.model.steps.StepListener; +import net.thucydides.model.steps.StepListenerAdapter; -import java.time.ZonedDateTime; -import java.util.List; -import java.util.Map; +public class RestStepListener extends StepListenerAdapter { -public class RestStepListener implements StepListener { - - @Override - public void testSuiteStarted(Class storyClass) { - - } - - @Override - public void testSuiteStarted(Story story) { - - } - - @Override - public void testSuiteFinished() { - - } - - @Override - public void testStarted(String description) { - - } - - @Override - public void testStarted(String description, String id) { - - } - - @Override - public void testStarted(String description, String id, ZonedDateTime startTime) { - - } - - @Override - public void testFinished(TestOutcome result) { - - } - - @Override - public void testFinished(TestOutcome result, boolean isInDataDrivenTest, ZonedDateTime finishTime) { - - } - - @Override - public void testRetried() { - - } - - @Override - public void stepStarted(ExecutedStepDescription description) { - - } - - @Override - public void skippedStepStarted(ExecutedStepDescription description) { - - } - - @Override - public void stepFailed(StepFailure failure) { - - } - - @Override - public void stepFailed(StepFailure failure, List screenshotList) { - - } - - @Override - public void lastStepFailed(StepFailure failure) { - - } - - @Override - public void stepIgnored() { - - } - - @Override - public void stepPending() { - - } - - @Override - public void stepPending(String message) { - - } - - @Override - public void stepFinished() { - - } - - @Override - public void stepFinished(List screenshotList) { - - } - - @Override - public void stepFinished(List screenshotList, ZonedDateTime time) { - - } - - @Override - public void testFailed(TestOutcome testOutcome, Throwable cause) { - - } - - @Override - public void testIgnored() { - - } - - @Override - public void testSkipped() { - - } - - @Override - public void testPending() { - - } - - @Override - public void testIsManual() { - - } - - @Override - public void notifyScreenChange() { - - } - - @Override - public void useExamplesFrom(DataTable table) { - - } - - @Override - public void addNewExamplesFrom(DataTable table) { - - } - - @Override - public void exampleStarted(Map data) { - - } - - @Override - public void exampleFinished() { - - } - - @Override - public void assumptionViolated(String message) { - - } - - @Override - public void testRunFinished() { - } - - @Override - public void takeScreenshots(List screenshots) { - - } - - @Override - public void takeScreenshots(TestResult testResult, List screenshots) { - - } } diff --git a/serenity-screenplay/src/main/java/net/serenitybdd/screenplay/facts/FactLifecycleListener.java b/serenity-screenplay/src/main/java/net/serenitybdd/screenplay/facts/FactLifecycleListener.java index bf557c001..773c1aaba 100644 --- a/serenity-screenplay/src/main/java/net/serenitybdd/screenplay/facts/FactLifecycleListener.java +++ b/serenity-screenplay/src/main/java/net/serenitybdd/screenplay/facts/FactLifecycleListener.java @@ -1,21 +1,13 @@ package net.serenitybdd.screenplay.facts; import net.serenitybdd.screenplay.Actor; -import net.thucydides.model.domain.DataTable; -import net.thucydides.model.domain.Story; import net.thucydides.model.domain.TestOutcome; -import net.thucydides.model.domain.TestResult; -import net.thucydides.model.screenshots.ScreenshotAndHtmlSource; import net.thucydides.core.steps.Droppable; -import net.thucydides.model.steps.ExecutedStepDescription; -import net.thucydides.model.steps.StepFailure; -import net.thucydides.model.steps.StepListener; +import net.thucydides.model.steps.StepListenerAdapter; import java.time.ZonedDateTime; -import java.util.List; -import java.util.Map; -public class FactLifecycleListener implements StepListener, Droppable { +public class FactLifecycleListener extends StepListenerAdapter implements Droppable { private final Actor actor; private final Fact fact; @@ -24,35 +16,6 @@ public FactLifecycleListener(Actor actor, Fact fact) { this.actor = actor; } - @Override - public void testSuiteStarted(Class storyClass) { - - } - - @Override - public void testSuiteStarted(Story story) { - - } - - @Override - public void testSuiteFinished() { - } - - @Override - public void testStarted(String description) { - - } - - @Override - public void testStarted(String description, String id) { - - } - - @Override - public void testStarted(String description, String id, ZonedDateTime startTime) { - - } - @Override public void testFinished(TestOutcome result) { fact.teardown(actor); @@ -62,139 +25,4 @@ public void testFinished(TestOutcome result) { public void testFinished(TestOutcome result, boolean isInDataDrivenTest, ZonedDateTime finishTime) { fact.teardown(actor); } - - @Override - public void testRetried() { - - } - - @Override - public void stepStarted(ExecutedStepDescription description) { - - } - - @Override - public void skippedStepStarted(ExecutedStepDescription description) { - - } - - @Override - public void stepFailed(StepFailure failure) { - - } - - @Override - public void stepFailed(StepFailure failure, List screenshotList) { - - } - - @Override - public void lastStepFailed(StepFailure failure) { - - } - - @Override - public void stepIgnored() { - - } - - @Override - public void stepPending() { - - } - - @Override - public void stepPending(String message) { - - } - - @Override - public void stepFinished() { - - } - - @Override - public void stepFinished(List screenshotList) { - - } - - @Override - public void stepFinished(List screenshotList, ZonedDateTime time) { - - } - - @Override - public void testFailed(TestOutcome testOutcome, Throwable cause) { - - } - - @Override - public void testIgnored() { - - } - - @Override - public void testSkipped() { - - } - - @Override - public void testAborted() { - - } - - @Override - public void testPending() { - - } - - @Override - public void testIsManual() { - - } - - @Override - public void notifyScreenChange() { - - } - - @Override - public void useExamplesFrom(DataTable table) { - - } - - @Override - public void addNewExamplesFrom(DataTable table) { - - } - - @Override - public void exampleStarted(Map data) { - - } - - @Override - public void exampleFinished() { - - } - - @Override - public void assumptionViolated(String message) { - - } - - @Override - public void testRunFinished() { - - } - - @Override - public void takeScreenshots(List screenshots) { - - } - - @Override - public void takeScreenshots(TestResult testResult, List screenshots) { - - } }