Package net.thucydides.core.steps
Class BaseStepListener
java.lang.Object
net.thucydides.core.steps.BaseStepListener
- All Implemented Interfaces:
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 ClassesModifier and TypeClassDescriptionprotected static enumclassclass -
Constructor Summary
ConstructorsConstructorDescriptionBaseStepListener(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
Modifier and TypeMethodDescriptionvoidaddChildStepsFrom(List<TestStep> newSteps) voidaddIssuesToCurrentStory(List<String> issues) voidaddNewExamplesFrom(DataTable table) voidaddStepsFrom(List<TestStep> newSteps) voidaddTagsToCurrentStory(List<TestTag> tags) voidassumptionViolated(String message) booleanShould return true if a step failure has been logged.booleanvoidchildListenerFor(StepEventBus eventBus) voidvoidvoidvoidvoidexampleStarted(Map<String, String> data) voidexampleStarted(Map<String, String> data, String exampleName) voidexceptionExpected(Class<? extends Throwable> expected) protected SystemClockgetClock()intorg.openqa.selenium.WebDriverThe currently-used WebDriver instance for these tests.protected WebdriverProxyFactoryintintIf a test failed, what was the error.A step listener should be able to return a set of test results at the end of the test run.booleanvoidlastStepFailed(StepFailure failure) voidlastTestPassedAfterRetries(int attemptNum, List<String> failureMessages, TestFailureCause testfailureCause) mergeLast(int maxStepsToMerge) voidvoidvoidoverrideResultTo(TestResult result) voidrecordManualTestResult(TestResult result) voidrecordManualTestResult(TestResult result, Optional<String> lastTestedVersion, Boolean isUpToDate, Optional<String> testEvidence) voidrecordRestQuery(RestQuery restQuery) protected ScreenshotPermissionvoidsetAllStepsTo(TestResult result) voidsetDriver(org.openqa.selenium.WebDriver driver) Used to update the webdriver driver for screenshots if a listener is reused between scenarios.voidsetEventBus(StepEventBus eventBus) voidskippedStepStarted(ExecutedStepDescription description) Creates a new base step listener withvoidstepFailed(StepFailure failure) voidstepFailedWithException(Throwable failure) voidvoidvoidvoidstepPending(String message) voidstepStarted(ExecutedStepDescription description) A step within a test is called.voidTake a screenshot now.voidvoidtestFailed(TestOutcome testOutcome, Throwable cause) voidtestFinished(TestOutcome outcome) voidtestFinished(TestOutcome outcome, boolean inDataDrivenTest) A test has finished.voidvoidvoidvoidvoidvoidvoidtestStarted(String testMethod) An individual test starts.voidtestStarted(String testMethod, String id) voidbooleanvoidtestSuiteStarted(Class<?> startedTestSuite) A test suite (containing a series of tests) starts.voidtestSuiteStarted(Story story) voidupdateCurrentStepFailureCause(Throwable failure) updateCurrentStepTitle(String updatedStepTitle) voidupdateExampleLineNumber(int lineNumber) voidvoiduseExamplesFrom(DataTable table) The current scenario is a data-driven scenario using test data from the specified table.
-
Constructor Details
-
BaseStepListener
-
BaseStepListener
-
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
-
BaseStepListener
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 Details
-
setEventBus
-
getEventBus
-
cloneCurrentStep
-
getAnnotatedResult
-
setAllStepsTo
-
overrideResultTo
-
recordManualTestResult
-
recordManualTestResult
-
exceptionExpected
-
mergeLast
-
getStepCount
public int getStepCount() -
getRunningStepCount
public int getRunningStepCount() -
updateOverallResults
public void updateOverallResults() -
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) -
addStepsFrom
-
addChildStepsFrom
-
childListenerFor
-
spawn
Creates a new base step listener with- Parameters:
outcomeName-- Returns:
-
screenshots
-
getProxyFactory
-
getCurrentTestOutcome
-
isAvailable
public boolean isAvailable() -
latestTestOutcome
-
getClock
-
testSuiteStarted
A test suite (containing a series of tests) starts.- Specified by:
testSuiteStartedin interfaceStepListener- Parameters:
startedTestSuite- the class implementing the test suite (e.g. a JUnit test case)
-
testSuiteStarted
- Specified by:
testSuiteStartedin interfaceStepListener
-
testSuiteRunning
public boolean testSuiteRunning() -
addIssuesToCurrentStory
-
addTagsToCurrentStory
-
testSuiteFinished
public void testSuiteFinished()- Specified by:
testSuiteFinishedin interfaceStepListener
-
testStarted
An individual test starts.- Specified by:
testStartedin interfaceStepListener- Parameters:
testMethod- the name of the test method in the test suite class.
-
testStarted
- Specified by:
testStartedin interfaceStepListener
-
updateCurrentStepTitle
-
updateCurrentStepFailureCause
-
testFinished
- Specified by:
testFinishedin interfaceStepListener
-
testFinished
A test has finished.- Specified by:
testFinishedin interfaceStepListener- Parameters:
outcome- the result of the test that just finished.
-
testRetried
public void testRetried()- Specified by:
testRetriedin interfaceStepListener
-
stepStarted
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:
stepStartedin interfaceStepListener- Parameters:
description- the description of the test that is about to be run
-
skippedStepStarted
- Specified by:
skippedStepStartedin interfaceStepListener
-
getCurrentStepMethod
-
stepFinished
public void stepFinished()- Specified by:
stepFinishedin interfaceStepListener
-
stepFailed
- Specified by:
stepFailedin interfaceStepListener
-
stepFailedWithException
-
lastStepFailed
- Specified by:
lastStepFailedin interfaceStepListener
-
stepIgnored
public void stepIgnored()- Specified by:
stepIgnoredin interfaceStepListener
-
stepPending
public void stepPending()- Specified by:
stepPendingin interfaceStepListener
-
stepPending
- Specified by:
stepPendingin interfaceStepListener
-
assumptionViolated
- Specified by:
assumptionViolatedin interfaceStepListener
-
testRunFinished
public void testRunFinished()- Specified by:
testRunFinishedin interfaceStepListener
-
getCurrentLevel
public int getCurrentLevel() -
getForcedResult
-
clearForcedResult
public void clearForcedResult() -
getActiveDrivers
-
getTestOutcomes
Description copied from interface:StepPublisherA step listener should be able to return a set of test results at the end of the test run.- Specified by:
getTestOutcomesin interfaceStepPublisher
-
setDriver
public void setDriver(org.openqa.selenium.WebDriver driver) Description copied from interface:StepPublisherUsed to update the webdriver driver for screenshots if a listener is reused between scenarios.- Specified by:
setDriverin interfaceStepPublisher
-
getDriver
public org.openqa.selenium.WebDriver getDriver()Description copied from interface:StepPublisherThe currently-used WebDriver instance for these tests.- Specified by:
getDriverin interfaceStepPublisher
-
aStepHasFailed
public boolean aStepHasFailed()Description copied from interface:StepPublisherShould return true if a step failure has been logged. We need to share this information if multiple step libraries are used.- Specified by:
aStepHasFailedin interfaceStepPublisher
-
firstFailingStep
- Specified by:
firstFailingStepin interfaceStepPublisher
-
aStepHasFailedInTheCurrentExample
public boolean aStepHasFailedInTheCurrentExample() -
getTestFailureCause
Description copied from interface:StepPublisherIf a test failed, what was the error.- Specified by:
getTestFailureCausein interfaceStepPublisher
-
testFailed
- Specified by:
testFailedin interfaceStepListener
-
testIgnored
public void testIgnored()- Specified by:
testIgnoredin interfaceStepListener
-
testSkipped
public void testSkipped()- Specified by:
testSkippedin interfaceStepListener
-
testAborted
public void testAborted()- Specified by:
testAbortedin interfaceStepListener
-
testPending
public void testPending()- Specified by:
testPendingin interfaceStepListener
-
testIsManual
public void testIsManual()- Specified by:
testIsManualin interfaceStepListener
-
notifyScreenChange
public void notifyScreenChange()- Specified by:
notifyScreenChangein interfaceStepListener
-
notifyUIError
public void notifyUIError() -
takeScreenshot
public void takeScreenshot()Take a screenshot now. -
useExamplesFrom
The current scenario is a data-driven scenario using test data from the specified table.- Specified by:
useExamplesFromin interfaceStepListener
-
addNewExamplesFrom
- Specified by:
addNewExamplesFromin interfaceStepListener
-
exampleStarted
- Specified by:
exampleStartedin interfaceStepListener
-
exampleStarted
- Specified by:
exampleStartedin interfaceStepListener
-
exampleFinished
public void exampleFinished()- Specified by:
exampleFinishedin interfaceStepListener
-
recordRestQuery
-
clearTestOutcomes
public void clearTestOutcomes()
-