Package net.thucydides.core.steps
Class BaseStepListener
- java.lang.Object
-
- net.thucydides.core.steps.BaseStepListener
-
- All Implemented Interfaces:
StepListener
,StepPublisher
public class BaseStepListener extends Object implements StepListener, StepPublisher
Observes the test run and stores test run details for later reporting. Observations are recorded in an TestOutcome object. This includes recording the names and results of each test, and taking and storing screenshots at strategic points during the tests.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
BaseStepListener.ScreenshotType
class
BaseStepListener.StepMerger
class
BaseStepListener.StepMutator
-
Constructor Summary
Constructors Constructor Description BaseStepListener(File outputDirectory)
BaseStepListener(File outputDirectory, com.google.inject.Injector injector)
BaseStepListener(File outputDirectory, Pages pages)
Create a step listener using the driver from a given page factory.BaseStepListener(File outputDirectory, WebdriverManager webdriverManager)
BaseStepListener(Class<? extends org.openqa.selenium.WebDriver> driverClass, File outputDirectory)
Create a step listener with a given web driver type.BaseStepListener(Class<? extends org.openqa.selenium.WebDriver> driverClass, File outputDirectory, Configuration configuration)
-
Method Summary
-
-
-
Constructor Detail
-
BaseStepListener
public BaseStepListener(File outputDirectory)
-
BaseStepListener
public BaseStepListener(File outputDirectory, com.google.inject.Injector injector)
-
BaseStepListener
public BaseStepListener(Class<? extends org.openqa.selenium.WebDriver> driverClass, File outputDirectory)
Create a step listener with a given web driver type.- Parameters:
driverClass
- a driver of this type will be usedoutputDirectory
- reports and screenshots are generated here
-
BaseStepListener
public BaseStepListener(Class<? extends org.openqa.selenium.WebDriver> driverClass, File outputDirectory, Configuration configuration)
-
BaseStepListener
public BaseStepListener(File outputDirectory, WebdriverManager webdriverManager)
-
BaseStepListener
public BaseStepListener(File outputDirectory, Pages pages)
Create a step listener using the driver from a given page factory. If the pages factory is null, a new driver will be created based on the default system values.- Parameters:
outputDirectory
- reports and screenshots are generated herepages
- a pages factory.
-
-
Method Detail
-
setEventBus
public void setEventBus(StepEventBus eventBus)
-
getEventBus
public StepEventBus getEventBus()
-
getAnnotatedResult
public Optional<TestResult> getAnnotatedResult()
-
setAllStepsTo
public void setAllStepsTo(TestResult result)
-
overrideResultTo
public void overrideResultTo(TestResult result)
-
recordManualTestResult
public void recordManualTestResult(TestResult result, Optional<String> lastTestedVersion, Boolean isUpToDate, Optional<String> testEvidence)
-
mergeLast
public BaseStepListener.StepMerger mergeLast(int maxStepsToMerge)
-
getStepCount
public int getStepCount()
-
getRunningStepCount
public int getRunningStepCount()
-
updateOverallResults
public void updateOverallResults()
-
getPhotographer
public Photographer getPhotographer()
-
cancelPreviousTest
public void cancelPreviousTest()
-
lastTestPassedAfterRetries
public void lastTestPassedAfterRetries(int attemptNum, List<String> failureMessages, TestFailureCause testfailureCause)
-
currentStepIsAPrecondition
public void currentStepIsAPrecondition()
-
updateExampleLineNumber
public void updateExampleLineNumber(int lineNumber)
-
screenshots
protected ScreenshotPermission screenshots()
-
getProxyFactory
protected WebdriverProxyFactory getProxyFactory()
-
getCurrentTestOutcome
public TestOutcome getCurrentTestOutcome()
-
isAvailable
public boolean isAvailable()
-
latestTestOutcome
public Optional<TestOutcome> latestTestOutcome()
-
getClock
protected SystemClock getClock()
-
testSuiteStarted
public void testSuiteStarted(Class<?> startedTestSuite)
A test suite (containing a series of tests) starts.- Specified by:
testSuiteStarted
in interfaceStepListener
- Parameters:
startedTestSuite
- the class implementing the test suite (e.g. a JUnit test case)
-
testSuiteStarted
public void testSuiteStarted(Story story)
- Specified by:
testSuiteStarted
in interfaceStepListener
-
testSuiteRunning
public boolean testSuiteRunning()
-
testSuiteFinished
public void testSuiteFinished()
- Specified by:
testSuiteFinished
in interfaceStepListener
-
testStarted
public void testStarted(String testMethod)
An individual test starts.- Specified by:
testStarted
in interfaceStepListener
- Parameters:
testMethod
- the name of the test method in the test suite class.
-
testStarted
public void testStarted(String testMethod, String id)
- Specified by:
testStarted
in interfaceStepListener
-
updateCurrentStepTitle
public BaseStepListener.StepMutator updateCurrentStepTitle(String updatedStepTitle)
-
updateCurrentStepFailureCause
public void updateCurrentStepFailureCause(Throwable failure)
-
testFinished
public void testFinished(TestOutcome outcome)
- Specified by:
testFinished
in interfaceStepListener
-
testFinished
public void testFinished(TestOutcome outcome, boolean inDataDrivenTest)
A test has finished.- Specified by:
testFinished
in interfaceStepListener
- Parameters:
outcome
- the result of the test that just finished.
-
testRetried
public void testRetried()
- Specified by:
testRetried
in interfaceStepListener
-
stepStarted
public void stepStarted(ExecutedStepDescription description)
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.- Specified by:
stepStarted
in interfaceStepListener
- Parameters:
description
- the description of the test that is about to be run
-
skippedStepStarted
public void skippedStepStarted(ExecutedStepDescription description)
- Specified by:
skippedStepStarted
in interfaceStepListener
-
stepFinished
public void stepFinished()
- Specified by:
stepFinished
in interfaceStepListener
-
stepFailed
public void stepFailed(StepFailure failure)
- Specified by:
stepFailed
in interfaceStepListener
-
stepFailedWithException
public void stepFailedWithException(Throwable failure)
-
lastStepFailed
public void lastStepFailed(StepFailure failure)
- Specified by:
lastStepFailed
in interfaceStepListener
-
stepIgnored
public void stepIgnored()
- Specified by:
stepIgnored
in interfaceStepListener
-
stepPending
public void stepPending()
- Specified by:
stepPending
in interfaceStepListener
-
stepPending
public void stepPending(String message)
- Specified by:
stepPending
in interfaceStepListener
-
assumptionViolated
public void assumptionViolated(String message)
- Specified by:
assumptionViolated
in interfaceStepListener
-
testRunFinished
public void testRunFinished()
- Specified by:
testRunFinished
in interfaceStepListener
-
getCurrentLevel
public int getCurrentLevel()
-
getForcedResult
public Optional<TestResult> getForcedResult()
-
clearForcedResult
public void clearForcedResult()
-
getTestOutcomes
public List<TestOutcome> getTestOutcomes()
Description copied from interface:StepPublisher
A step listener should be able to return a set of test results at the end of the test run.- Specified by:
getTestOutcomes
in interfaceStepPublisher
-
setDriver
public void setDriver(org.openqa.selenium.WebDriver driver)
Description copied from interface:StepPublisher
Used to update the webdriver driver for screenshots if a listener is reused between scenarios.- Specified by:
setDriver
in interfaceStepPublisher
-
getDriver
public org.openqa.selenium.WebDriver getDriver()
Description copied from interface:StepPublisher
The currently-used WebDriver instance for these tests.- Specified by:
getDriver
in interfaceStepPublisher
-
aStepHasFailed
public boolean aStepHasFailed()
Description copied from interface:StepPublisher
Should return true if a step failure has been logged. We need to share this information if multiple step libraries are used.- Specified by:
aStepHasFailed
in interfaceStepPublisher
-
aStepHasFailedInTheCurrentExample
public boolean aStepHasFailedInTheCurrentExample()
-
getTestFailureCause
public FailureCause getTestFailureCause()
Description copied from interface:StepPublisher
If a test failed, what was the error.- Specified by:
getTestFailureCause
in interfaceStepPublisher
-
testFailed
public void testFailed(TestOutcome testOutcome, Throwable cause)
- Specified by:
testFailed
in interfaceStepListener
-
testIgnored
public void testIgnored()
- Specified by:
testIgnored
in interfaceStepListener
-
testSkipped
public void testSkipped()
- Specified by:
testSkipped
in interfaceStepListener
-
testPending
public void testPending()
- Specified by:
testPending
in interfaceStepListener
-
testIsManual
public void testIsManual()
- Specified by:
testIsManual
in interfaceStepListener
-
notifyScreenChange
public void notifyScreenChange()
- Specified by:
notifyScreenChange
in interfaceStepListener
-
takeScreenshot
public void takeScreenshot()
Take a screenshot now.
-
useExamplesFrom
public void useExamplesFrom(DataTable table)
The current scenario is a data-driven scenario using test data from the specified table.- Specified by:
useExamplesFrom
in interfaceStepListener
-
addNewExamplesFrom
public void addNewExamplesFrom(DataTable table)
- Specified by:
addNewExamplesFrom
in interfaceStepListener
-
exampleStarted
public void exampleStarted(Map<String,String> data)
- Specified by:
exampleStarted
in interfaceStepListener
-
exampleStarted
public void exampleStarted(Map<String,String> data, String exampleName)
- Specified by:
exampleStarted
in interfaceStepListener
-
exampleFinished
public void exampleFinished()
- Specified by:
exampleFinished
in interfaceStepListener
-
recordRestQuery
public void recordRestQuery(RestQuery restQuery)
-
-