Package net.thucydides.core.steps
Class StepEventBus
java.lang.Object
net.thucydides.core.steps.StepEventBus
- Direct Known Subclasses:
SilentEventBus
public class StepEventBus
extends java.lang.Object
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
Constructors Constructor Description StepEventBus(EnvironmentVariables environmentVariables, Configuration configuration) -
Method Summary
Modifier and Type Method Description voidaddDescriptionToCurrentTest(java.lang.String description)voidaddIssuesToCurrentStory(java.util.List<java.lang.String> issues)voidaddIssuesToCurrentTest(java.util.List<java.lang.String> issues)voidaddNewExamplesFrom(DataTable newTable)voidaddTagsToCurrentStory(java.util.List<TestTag> tags)voidaddTagsToCurrentTest(java.util.List<TestTag> tags)booleanareStepsRunning()booleanassumptionViolated()voidassumptionViolated(java.lang.String message)booleanaStepInTheCurrentTestHasFailed()voidcancelPreviousTest()voidcastActor(java.lang.String name)voidclear()static voidclearEventBusFor(java.lang.Object key)voidclearStepFailures()booleancurrentTestIsSuspended()booleancurrentTestOutcomeIsDataDriven()voiddisableSoftAsserts()voiddropAgent(Agent agent)voiddropAgents(Agent... agents)voiddropAllListeners()voiddropListener(StepListener stepListener)voidenableDryRun()voidenableSoftAsserts()static StepEventBuseventBusFor(java.lang.Object key)voidexampleFinished()voidexampleStarted(java.util.Map<java.lang.String,java.lang.String> data)voidexampleStarted(java.util.Map<java.lang.String,java.lang.String> data, java.lang.String exampleName)voidexceptionExpected(java.lang.Class<? extends java.lang.Throwable> expected)voidfinishTestRun()protected java.util.List<StepListener>getAllListeners()java.lang.StringgetAssumptionViolatedMessage()BaseStepListenergetBaseStepListener()java.util.Optional<TestStep>getCurrentStep()EnvironmentVariablesgetEnvironmentVariables()static StepEventBusgetEventBus()The event bus used to inform listening classes about when tests and test steps start and finish.java.util.Optional<TestResult>getForcedResult()java.lang.StringgetTestSource()voidinitialiseSession()booleanisBaseStepListenerRegistered()booleanisCurrentTestDataDriven()booleanisDryRun()booleanisUniqueSession()voidlastStepFailed(StepFailure failure)voidlastTestPassedAfterRetries(int remainingTries, java.util.List<java.lang.String> failureMessages, TestFailureCause testFailureCause)voidmergeActivitiesToDefaultStepListener(java.lang.String stepName, Agent... agents)voidmergeActivitiesToDefaultStepListener(Agent... agents)voidmergePreviousStep()voidnotifyScreenChange()static voidoverrideEventBusWith(StepEventBus stepEventBus)voidreenableWebDriver()voidreenableWebdriverCalls()voidregisterAgent(Agent agent)voidregisterAgents(Agent... agents)StepEventBusregisterListener(StepListener listener)Register a listener to receive notification at different points during a test's execution.voidreset()java.util.Optional<TestResult>resultSoFar()voidsetAllStepsTo(TestResult result)Set all steps in the current test outcome to a given result.voidsetBackgroundDescription(java.lang.String description)voidsetBackgroundTitle(java.lang.String title)static voidsetCurrentBusToEventBusFor(java.lang.Object key)voidsetRule(Rule rule)voidsetTestSource(java.lang.String testSource)voidsetUniqueSession(boolean uniqueSession)voidskippedStepStarted(ExecutedStepDescription executedStepDescription)Record a step that is not scheduled to be executed (e.g.booleansoftAssertsActive()voidstepFailed(StepFailure failure)voidstepFinished()voidstepIgnored()voidstepPending()voidstepPending(java.lang.String message)voidstepStarted(ExecutedStepDescription stepDescription)Start the execution of a test step.voidstepStarted(ExecutedStepDescription stepDescription, boolean isPrecondition)Start the execution of a test step.voidsuspendTest()voidsuspendTest(TestResult result)voidtakeScreenshot()Forces Thucydides to take a screenshot now.voidtemporarilySuspendWebdriverCalls()voidtestFailed(java.lang.Throwable cause)The test failed, but not during the execution of a step.voidtestFinished()voidtestFinished(boolean inDataDrivenTest)voidtestFinished(TestOutcome result)voidtestIgnored()voidtestIsManual()Mark the current test method as pending.voidtestPending()Mark the current test method as pending.voidtestRetried()voidtestRunFinished()voidtestSkipped()voidtestStarted(java.lang.String testName)voidtestStarted(java.lang.String newTestName, java.lang.Class<?> testClass)voidtestStarted(java.lang.String testName, java.lang.String id)voidtestStarted(java.lang.String newTestName, Story story)voidtestSuiteFinished()booleantestSuiteHasStarted()voidtestSuiteStarted(java.lang.Class<?> testClass)voidtestSuiteStarted(Story story)voidunsuspend()Removes a test suspensionvoidupdateCurrentStepTitle(java.lang.String stepTitle)voidupdateCurrentStepTitleAsPrecondition(java.lang.String stepTitle)voidupdateExampleLineNumber(int lineNumber)voidupdateOverallResults()voiduseExamplesFrom(DataTable table)voiduseScenarioOutline(java.lang.String scenarioOutline)booleanwebdriverCallsAreSuspended()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Constructor Details
-
StepEventBus
@Inject public StepEventBus(EnvironmentVariables environmentVariables, Configuration configuration)
-
-
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
public static void setCurrentBusToEventBusFor(java.lang.Object key) -
clearEventBusFor
public static void clearEventBusFor(java.lang.Object key) -
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
public void testStarted(java.lang.String testName) -
testStarted
public void testStarted(java.lang.String testName, java.lang.String id) -
isUniqueSession
public boolean isUniqueSession() -
setUniqueSession
public void setUniqueSession(boolean uniqueSession) -
testStarted
-
testStarted
public void testStarted(java.lang.String newTestName, java.lang.Class<?> testClass) -
getAllListeners
-
testSuiteStarted
public void testSuiteStarted(java.lang.Class<?> testClass) -
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
public void stepPending(java.lang.String message) -
assumptionViolated
public void assumptionViolated(java.lang.String message) -
dropListener
-
dropAllListeners
public void dropAllListeners() -
reenableWebDriver
public void reenableWebDriver() -
webdriverCallsAreSuspended
public boolean webdriverCallsAreSuspended() -
reenableWebdriverCalls
public void reenableWebdriverCalls() -
temporarilySuspendWebdriverCalls
public void temporarilySuspendWebdriverCalls() -
testFailed
public void testFailed(java.lang.Throwable cause)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
public void useScenarioOutline(java.lang.String scenarioOutline) -
currentTestIsSuspended
public boolean currentTestIsSuspended() -
assumptionViolated
public boolean assumptionViolated() -
testIgnored
public void testIgnored() -
testSkipped
public void testSkipped() -
areStepsRunning
public boolean areStepsRunning() -
notifyScreenChange
public void notifyScreenChange() -
testSuiteFinished
public void testSuiteFinished() -
testRunFinished
public void testRunFinished() -
updateCurrentStepTitle
public void updateCurrentStepTitle(java.lang.String stepTitle) -
updateCurrentStepTitleAsPrecondition
public void updateCurrentStepTitleAsPrecondition(java.lang.String stepTitle) -
addIssuesToCurrentStory
public void addIssuesToCurrentStory(java.util.List<java.lang.String> issues) -
addIssuesToCurrentTest
public void addIssuesToCurrentTest(java.util.List<java.lang.String> issues) -
addTagsToCurrentTest
-
addTagsToCurrentStory
-
addDescriptionToCurrentTest
public void addDescriptionToCurrentTest(java.lang.String description) -
setBackgroundTitle
public void setBackgroundTitle(java.lang.String title) -
setBackgroundDescription
public void setBackgroundDescription(java.lang.String description) -
setRule
-
useExamplesFrom
-
addNewExamplesFrom
-
exampleStarted
public void exampleStarted(java.util.Map<java.lang.String,java.lang.String> data) -
exampleStarted
public void exampleStarted(java.util.Map<java.lang.String,java.lang.String> data, java.lang.String exampleName) -
exampleFinished
public void exampleFinished() -
currentTestOutcomeIsDataDriven
public boolean currentTestOutcomeIsDataDriven() -
takeScreenshot
public void takeScreenshot()Forces Thucydides to take a screenshot now. -
testSuiteHasStarted
public boolean testSuiteHasStarted() -
getAssumptionViolatedMessage
public java.lang.String 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
public void exceptionExpected(java.lang.Class<? extends java.lang.Throwable> expected) -
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
public java.lang.String getTestSource() -
setTestSource
public void setTestSource(java.lang.String testSource) -
cancelPreviousTest
public void cancelPreviousTest() -
lastTestPassedAfterRetries
public void lastTestPassedAfterRetries(int remainingTries, java.util.List<java.lang.String> failureMessages, TestFailureCause testFailureCause) -
overrideEventBusWith
-
castActor
public void castActor(java.lang.String name) -
initialiseSession
public void initialiseSession() -
registerAgent
-
registerAgents
-
dropAgents
-
dropAgent
-
mergeActivitiesToDefaultStepListener
-
mergeActivitiesToDefaultStepListener
-