Class StepEventBus

  • Direct Known Subclasses:
    SilentEventBus

    public class StepEventBus
    extends 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.
    • Method Detail

      • getEventBus

        public static StepEventBus 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.
      • setCurrentBusToEventBusFor

        public static void setCurrentBusToEventBusFor​(Object key)
      • clearEventBusFor

        public static void clearEventBusFor​(Object key)
      • registerListener

        public StepEventBus registerListener​(StepListener listener)
        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()
      • testStarted

        public void testStarted​(String testName)
      • testStarted

        public void testStarted​(String testName,
                                String id)
      • isUniqueSession

        public boolean isUniqueSession()
      • setUniqueSession

        public void setUniqueSession​(boolean uniqueSession)
      • testStarted

        public void testStarted​(String newTestName,
                                Story story)
      • testStarted

        public void testStarted​(String newTestName,
                                Class<?> testClass)
      • testSuiteStarted

        public void testSuiteStarted​(Class<?> testClass)
      • updateExampleLineNumber

        public void updateExampleLineNumber​(int lineNumber)
      • testSuiteStarted

        public void testSuiteStarted​(Story story)
      • clear

        public void clear()
      • unsuspend

        public void unsuspend()
        Removes a test suspension
      • testFinished

        public void testFinished​(boolean inDataDrivenTest)
      • testFinished

        public void testFinished()
      • testFinished

        public void testFinished​(TestOutcome result)
      • testRetried

        public void testRetried()
      • clearStepFailures

        public void clearStepFailures()
      • aStepInTheCurrentTestHasFailed

        public boolean aStepInTheCurrentTestHasFailed()
      • isCurrentTestDataDriven

        public boolean isCurrentTestDataDriven()
      • stepStarted

        public void stepStarted​(ExecutedStepDescription stepDescription)
        Start the execution of a test step.
      • stepStarted

        public void stepStarted​(ExecutedStepDescription stepDescription,
                                boolean isPrecondition)
        Start the execution of a test step.
      • skippedStepStarted

        public void skippedStepStarted​(ExecutedStepDescription executedStepDescription)
        Record a step that is not scheduled to be executed (e.g. a skipped or ignored step).
      • stepFinished

        public void stepFinished()
      • stepFailed

        public void stepFailed​(StepFailure failure)
      • lastStepFailed

        public void lastStepFailed​(StepFailure failure)
      • stepIgnored

        public void stepIgnored()
      • stepPending

        public void stepPending()
      • stepPending

        public void stepPending​(String message)
      • assumptionViolated

        public void assumptionViolated​(String message)
      • dropListener

        public void dropListener​(StepListener stepListener)
      • dropAllListeners

        public void dropAllListeners()
      • reenableWebDriver

        public void reenableWebDriver()
      • webdriverCallsAreSuspended

        public boolean webdriverCallsAreSuspended()
      • reenableWebdriverCalls

        public void reenableWebdriverCalls()
      • temporarilySuspendWebdriverCalls

        public void temporarilySuspendWebdriverCalls()
      • testFailed

        public void testFailed​(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

        public void suspendTest​(TestResult result)
      • useScenarioOutline

        public void useScenarioOutline​(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​(String stepTitle)
      • updateCurrentStepTitleAsPrecondition

        public void updateCurrentStepTitleAsPrecondition​(String stepTitle)
      • addIssuesToCurrentStory

        public void addIssuesToCurrentStory​(List<String> issues)
      • addIssuesToCurrentTest

        public void addIssuesToCurrentTest​(List<String> issues)
      • addTagsToCurrentTest

        public void addTagsToCurrentTest​(List<TestTag> tags)
      • addTagsToCurrentStory

        public void addTagsToCurrentStory​(List<TestTag> tags)
      • addDescriptionToCurrentTest

        public void addDescriptionToCurrentTest​(String description)
      • setBackgroundTitle

        public void setBackgroundTitle​(String title)
      • setBackgroundDescription

        public void setBackgroundDescription​(String description)
      • setRule

        public void setRule​(Rule rule)
      • useExamplesFrom

        public void useExamplesFrom​(DataTable table)
      • addNewExamplesFrom

        public void addNewExamplesFrom​(DataTable newTable)
      • exampleStarted

        public void exampleStarted​(Map<String,​String> data)
      • 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 String getAssumptionViolatedMessage()
      • setAllStepsTo

        public void setAllStepsTo​(TestResult result)
        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 -
      • isDryRun

        public boolean isDryRun()
      • enableDryRun

        public void enableDryRun()
      • exceptionExpected

        public void exceptionExpected​(Class<? extends Throwable> expected)
      • 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 String getTestSource()
      • setTestSource

        public void setTestSource​(String testSource)
      • cancelPreviousTest

        public void cancelPreviousTest()
      • lastTestPassedAfterRetries

        public void lastTestPassedAfterRetries​(int remainingTries,
                                               List<String> failureMessages,
                                               TestFailureCause testFailureCause)
      • overrideEventBusWith

        public static void overrideEventBusWith​(StepEventBus stepEventBus)
      • castActor

        public void castActor​(String name)
      • initialiseSession

        public void initialiseSession()