Package net.thucydides.core.steps
Class StepEventBus
java.lang.Object
net.thucydides.core.steps.StepEventBus
- Direct Known Subclasses:
SilentEventBus
An event bus for Step-related notifications.
Use this to integrate Thucydides listeners with testing tools.
You create a listener (e.g. an instance of BaseStepListener, or your own), register it using
'registerListener', and then implement the various methods (testStarted(), stepStarted()). Thucydides
will call these events on your listener as they occur.
You can register a new Thucydides listener by implementing the StepListener interface and
placing your class in the classpath. Thucydides will automatically detect the listener and add it to the
registered listeners. It will load custom listeners automatically when a test starts for the first time.
-
Constructor Summary
ConstructorsConstructorDescriptionStepEventBus
(EnvironmentVariables environmentVariables, Configuration configuration) -
Method Summary
Modifier and TypeMethodDescriptionvoid
addDescriptionToCurrentTest
(String description) void
addIssuesToCurrentStory
(List<String> issues) void
addIssuesToCurrentTest
(List<String> issues) void
addNewExamplesFrom
(DataTable newTable) void
addTagsToCurrentStory
(List<TestTag> tags) void
addTagsToCurrentTest
(List<TestTag> tags) boolean
boolean
void
assumptionViolated
(String message) boolean
void
void
void
clear()
static void
clearEventBusFor
(Object key) void
boolean
boolean
void
void
void
dropAgents
(Agent... agents) void
void
dropListener
(StepListener stepListener) void
void
static StepEventBus
eventBusFor
(Object key) void
void
exampleStarted
(Map<String, String> data) void
exampleStarted
(Map<String, String> data, String exampleName) void
exceptionExpected
(Class<? extends Throwable> expected) void
protected List<StepListener>
static StepEventBus
The event bus used to inform listening classes about when tests and test steps start and finish.void
boolean
boolean
boolean
isDryRun()
boolean
void
lastStepFailed
(StepFailure failure) void
lastTestPassedAfterRetries
(int remainingTries, List<String> failureMessages, TestFailureCause testFailureCause) void
mergeActivitiesToDefaultStepListener
(String stepName, Agent... agents) void
mergeActivitiesToDefaultStepListener
(Agent... agents) void
void
void
static void
overrideEventBusWith
(StepEventBus stepEventBus) void
void
void
registerAgent
(Agent agent) void
registerAgents
(Agent... agents) registerListener
(StepListener listener) Register a listener to receive notification at different points during a test's execution.void
reset()
void
setAllStepsTo
(TestResult result) Set all steps in the current test outcome to a given result.void
setBackgroundDescription
(String description) void
setBackgroundTitle
(String title) static void
void
void
setTestSource
(String testSource) void
setUniqueSession
(boolean uniqueSession) void
skippedStepStarted
(ExecutedStepDescription executedStepDescription) Record a step that is not scheduled to be executed (e.g.boolean
void
stepFailed
(StepFailure failure) void
void
void
void
stepPending
(String message) void
stepStarted
(ExecutedStepDescription stepDescription) Start the execution of a test step.void
stepStarted
(ExecutedStepDescription stepDescription, boolean isPrecondition) Start the execution of a test step.void
void
suspendTest
(TestResult result) void
Forces Thucydides to take a screenshot now.void
void
void
testFailed
(Throwable cause) The test failed, but not during the execution of a step.void
void
testFinished
(boolean inDataDrivenTest) void
testFinished
(TestOutcome result) void
void
Mark the current test method as pending.void
Mark the current test method as pending.void
void
void
void
testStarted
(String testName) void
testStarted
(String newTestName, Class<?> testClass) void
testStarted
(String testName, String id) void
testStarted
(String newTestName, Story story) void
boolean
void
testSuiteStarted
(Class<?> testClass) void
testSuiteStarted
(Story story) void
Removes a test suspensionvoid
updateCurrentStepTitle
(String stepTitle) void
updateCurrentStepTitleAsPrecondition
(String stepTitle) void
updateExampleLineNumber
(int lineNumber) void
void
useExamplesFrom
(DataTable table) void
useScenarioOutline
(String scenarioOutline) boolean
-
Constructor Details
-
StepEventBus
-
-
Method Details
-
getEventBus
The event bus used to inform listening classes about when tests and test steps start and finish. There is a separate event bus for each thread. -
eventBusFor
- Parameters:
key
-- Returns:
-
setCurrentBusToEventBusFor
-
clearEventBusFor
-
getEnvironmentVariables
-
registerListener
Register a listener to receive notification at different points during a test's execution. If you are writing your own listener, you shouldn't need to call this method - just set up your listener implementation as a service (see http://download.oracle.com/javase/6/docs/api/java/util/ServiceLoader.html), place the listener class on the classpath and it will be detected automatically. -
isBaseStepListenerRegistered
public boolean isBaseStepListenerRegistered() -
getBaseStepListener
-
testStarted
-
testStarted
-
isUniqueSession
public boolean isUniqueSession() -
setUniqueSession
public void setUniqueSession(boolean uniqueSession) -
testStarted
-
testStarted
-
getAllListeners
-
testSuiteStarted
-
updateExampleLineNumber
public void updateExampleLineNumber(int lineNumber) -
testSuiteStarted
-
clear
public void clear() -
unsuspend
public void unsuspend()Removes a test suspension -
testFinished
public void testFinished(boolean inDataDrivenTest) -
finishTestRun
public void finishTestRun() -
testFinished
public void testFinished() -
testFinished
-
testRetried
public void testRetried() -
clearStepFailures
public void clearStepFailures() -
aStepInTheCurrentTestHasFailed
public boolean aStepInTheCurrentTestHasFailed() -
isCurrentTestDataDriven
public boolean isCurrentTestDataDriven() -
stepStarted
Start the execution of a test step. -
stepStarted
Start the execution of a test step. -
skippedStepStarted
Record a step that is not scheduled to be executed (e.g. a skipped or ignored step). -
stepFinished
public void stepFinished() -
stepFailed
-
lastStepFailed
-
stepIgnored
public void stepIgnored() -
stepPending
public void stepPending() -
stepPending
-
assumptionViolated
-
dropListener
-
dropAllListeners
public void dropAllListeners() -
reenableWebDriver
public void reenableWebDriver() -
webdriverCallsAreSuspended
public boolean webdriverCallsAreSuspended() -
reenableWebdriverCalls
public void reenableWebdriverCalls() -
temporarilySuspendWebdriverCalls
public void temporarilySuspendWebdriverCalls() -
testFailed
The test failed, but not during the execution of a step.- Parameters:
cause
- the underlying cause of the failure.
-
testPending
public void testPending()Mark the current test method as pending. The test will stil be executed to record the steps, but any webdriver calls will be skipped. -
testIsManual
public void testIsManual()Mark the current test method as pending. The test will stil be executed to record the steps, but any webdriver calls will be skipped. -
suspendTest
public void suspendTest() -
suspendTest
-
useScenarioOutline
-
currentTestIsSuspended
public boolean currentTestIsSuspended() -
assumptionViolated
public boolean assumptionViolated() -
testIgnored
public void testIgnored() -
testSkipped
public void testSkipped() -
testAborted
public void testAborted() -
areStepsRunning
public boolean areStepsRunning() -
notifyScreenChange
public void notifyScreenChange() -
testSuiteFinished
public void testSuiteFinished() -
testRunFinished
public void testRunFinished() -
updateCurrentStepTitle
-
updateCurrentStepTitleAsPrecondition
-
addIssuesToCurrentStory
-
addIssuesToCurrentTest
-
addTagsToCurrentTest
-
addTagsToCurrentStory
-
addDescriptionToCurrentTest
-
setBackgroundTitle
-
setBackgroundDescription
-
setRule
-
useExamplesFrom
-
addNewExamplesFrom
-
exampleStarted
-
exampleStarted
-
exampleFinished
public void exampleFinished() -
currentTestOutcomeIsDataDriven
public boolean currentTestOutcomeIsDataDriven() -
takeScreenshot
public void takeScreenshot()Forces Thucydides to take a screenshot now. -
notifyFailure
public void notifyFailure() -
testSuiteHasStarted
public boolean testSuiteHasStarted() -
getAssumptionViolatedMessage
-
getCurrentStep
-
setAllStepsTo
Set all steps in the current test outcome to a given result. Used to set all steps to PENDING or SKIPPED, for example.- Parameters:
result
-
-
getForcedResult
-
isDryRun
public boolean isDryRun() -
enableDryRun
public void enableDryRun() -
exceptionExpected
-
resultSoFar
-
mergePreviousStep
public void mergePreviousStep() -
updateOverallResults
public void updateOverallResults() -
reset
public void reset() -
disableSoftAsserts
public void disableSoftAsserts() -
enableSoftAsserts
public void enableSoftAsserts() -
softAssertsActive
public boolean softAssertsActive() -
getTestSource
-
setTestSource
-
cancelPreviousTest
public void cancelPreviousTest() -
lastTestPassedAfterRetries
public void lastTestPassedAfterRetries(int remainingTries, List<String> failureMessages, TestFailureCause testFailureCause) -
overrideEventBusWith
-
castActor
-
initialiseSession
public void initialiseSession() -
registerAgent
-
registerAgents
-
dropAgents
-
dropAgent
-
mergeActivitiesToDefaultStepListener
-
mergeActivitiesToDefaultStepListener
-