net.thucydides.core.steps
Class BaseStepListener

Package class diagram package BaseStepListener
java.lang.Object
  extended by net.thucydides.core.steps.BaseStepListener
All Implemented Interfaces:
StepListener, StepPublisher
Direct Known Subclasses:
ConsoleStepListener

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
protected static class BaseStepListener.ScreenshotType
           
 
Constructor Summary
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)
           
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)
           
 
Method Summary
 void addIssuesToCurrentStory(List<String> issues)
           
 void addTagsToCurrentStory(List<TestTag> tags)
           
 void assumptionViolated(String message)
           
 boolean aStepHasFailed()
          Should return true if a step failure has been logged.
 void exampleFinished()
          An example has finished.
 void exampleStarted(Map<String,String> data)
          A new example has just started.
protected  SystemClock getClock()
           
protected  TestOutcome getCurrentTestOutcome()
           
 org.openqa.selenium.WebDriver getDriver()
          The currently-used WebDriver instance for these tests.
 StepEventBus getEventBus()
           
 Photographer getPhotographer()
           
protected  WebdriverProxyFactory getProxyFactory()
           
 Throwable getTestFailureCause()
          If a test failed, what was the error.
 List<TestOutcome> getTestOutcomes()
          A step listener should be able to return a set of test results at the end of the test run.
 void lastStepFailed(StepFailure failure)
          Declare that a step has failed after it has finished.
 void notifyScreenChange()
           
protected  ScreenshotPermission screenshots()
           
 void setDriver(org.openqa.selenium.WebDriver driver)
          Used to update the webdriver driver for screenshots if a listener is reused between scenarios.
 void setEventBus(StepEventBus eventBus)
           
 void skippedStepStarted(ExecutedStepDescription description)
          Called when a test step is about to be started, but this step is scheduled to be skipped.
 void stepFailed(StepFailure failure)
          Called when a test step fails.
 void stepFinished()
          Called when an test step has finished successfully
 void stepIgnored()
          Called when a step will not be run, generally because a test method is annotated with Ignore.
 void stepPending()
          The step is marked as pending.
 void stepPending(String message)
          The step is marked as pending with a descriptive message.
 void stepStarted(ExecutedStepDescription description)
          A step within a test is called.
 void takeScreenshot()
          Take a screenshot now.
 void testFailed(TestOutcome testOutcome, Throwable cause)
          The test failed, but not while executing a step.
 void testFinished(TestOutcome outcome)
          A test has finished.
 void testIgnored()
          The test as a whole was skipped or ignored.
 void testRetried()
          The last test run is about to be restarted
 void testStarted(String testMethod)
          An individual test starts.
 void testSuiteFinished()
          End of a test case or story.
 boolean testSuiteRunning()
           
 void testSuiteStarted(Class<?> startedTestSuite)
          A test suite (containing a series of tests) starts.
 void testSuiteStarted(Story story)
          Start a test run using a specific story, without a corresponding Java class.
 void updateCurrentStepTitle(String updatedStepTitle)
           
 void useExamplesFrom(DataTable table)
          The current scenario is a data-driven scenario using test data from the specified table.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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 used
outputDirectory - 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 here
pages - a pages factory.
Method Detail

setEventBus

public void setEventBus(StepEventBus eventBus)

getEventBus

public StepEventBus getEventBus()

screenshots

protected ScreenshotPermission screenshots()

getProxyFactory

protected WebdriverProxyFactory getProxyFactory()

getCurrentTestOutcome

protected TestOutcome getCurrentTestOutcome()

getClock

protected SystemClock getClock()

testSuiteStarted

public void testSuiteStarted(Class<?> startedTestSuite)
A test suite (containing a series of tests) starts.

Specified by:
testSuiteStarted in interface StepListener
Parameters:
startedTestSuite - the class implementing the test suite (e.g. a JUnit test case)

testSuiteStarted

public void testSuiteStarted(Story story)
Description copied from interface: StepListener
Start a test run using a specific story, without a corresponding Java class.

Specified by:
testSuiteStarted in interface StepListener

testSuiteRunning

public boolean testSuiteRunning()

addIssuesToCurrentStory

public void addIssuesToCurrentStory(List<String> issues)

addTagsToCurrentStory

public void addTagsToCurrentStory(List<TestTag> tags)

testSuiteFinished

public void testSuiteFinished()
Description copied from interface: StepListener
End of a test case or story.

Specified by:
testSuiteFinished in interface StepListener

testStarted

public void testStarted(String testMethod)
An individual test starts.

Specified by:
testStarted in interface StepListener
Parameters:
testMethod - the name of the test method in the test suite class.

updateCurrentStepTitle

public void updateCurrentStepTitle(String updatedStepTitle)

testFinished

public void testFinished(TestOutcome outcome)
A test has finished.

Specified by:
testFinished in interface StepListener
Parameters:
outcome - the result of the test that just finished.

testRetried

public void testRetried()
Description copied from interface: StepListener
The last test run is about to be restarted

Specified by:
testRetried in interface StepListener

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 interface StepListener
Parameters:
description - the description of the test that is about to be run

skippedStepStarted

public void skippedStepStarted(ExecutedStepDescription description)
Description copied from interface: StepListener
Called when a test step is about to be started, but this step is scheduled to be skipped.

Specified by:
skippedStepStarted in interface StepListener
Parameters:
description - the description of the test that is about to be run (generally a class and method name)

stepFinished

public void stepFinished()
Description copied from interface: StepListener
Called when an test step has finished successfully

Specified by:
stepFinished in interface StepListener

stepFailed

public void stepFailed(StepFailure failure)
Description copied from interface: StepListener
Called when a test step fails.

Specified by:
stepFailed in interface StepListener
Parameters:
failure - describes the test that failed and the exception that was thrown

lastStepFailed

public void lastStepFailed(StepFailure failure)
Description copied from interface: StepListener
Declare that a step has failed after it has finished.

Specified by:
lastStepFailed in interface StepListener

stepIgnored

public void stepIgnored()
Description copied from interface: StepListener
Called when a step will not be run, generally because a test method is annotated with Ignore.

Specified by:
stepIgnored in interface StepListener

stepPending

public void stepPending()
Description copied from interface: StepListener
The step is marked as pending.

Specified by:
stepPending in interface StepListener

stepPending

public void stepPending(String message)
Description copied from interface: StepListener
The step is marked as pending with a descriptive message.

Specified by:
stepPending in interface StepListener

assumptionViolated

public void assumptionViolated(String message)
Specified by:
assumptionViolated in interface StepListener

getPhotographer

public Photographer getPhotographer()

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 interface StepPublisher

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 interface StepPublisher

getDriver

public org.openqa.selenium.WebDriver getDriver()
Description copied from interface: StepPublisher
The currently-used WebDriver instance for these tests.

Specified by:
getDriver in interface StepPublisher

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 interface StepPublisher

getTestFailureCause

public Throwable getTestFailureCause()
Description copied from interface: StepPublisher
If a test failed, what was the error.

Specified by:
getTestFailureCause in interface StepPublisher

testFailed

public void testFailed(TestOutcome testOutcome,
                       Throwable cause)
Description copied from interface: StepListener
The test failed, but not while executing a step.

Specified by:
testFailed in interface StepListener
Parameters:
testOutcome - The test outcome structure for the failing test
cause - The exception that triggered the failure

testIgnored

public void testIgnored()
Description copied from interface: StepListener
The test as a whole was skipped or ignored.

Specified by:
testIgnored in interface StepListener

notifyScreenChange

public void notifyScreenChange()
Specified by:
notifyScreenChange in interface StepListener

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 interface StepListener

exampleStarted

public void exampleStarted(Map<String,String> data)
Description copied from interface: StepListener
A new example has just started.

Specified by:
exampleStarted in interface StepListener

exampleFinished

public void exampleFinished()
Description copied from interface: StepListener
An example has finished.

Specified by:
exampleFinished in interface StepListener


Copyright © 2011-2013 Wakaleo Consulting. All Rights Reserved.