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, Configuration configuration)
           
BaseStepListener(File outputDirectory, Pages pages)
          Create a step listener using the driver from a given page factory.
 
Method Summary
 boolean aStepHasFailed()
          Should return true if a step failure has been logged.
protected  SystemClock getClock()
           
protected  TestOutcome getCurrentTestOutcome()
           
 org.openqa.selenium.WebDriver getDriver()
          The currently-used WebDriver instance for these tests.
 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()
           
 void setDriver(org.openqa.selenium.WebDriver driver)
          Used to update the webdriver driver for screenshots if a listener is reused between scenarios.
 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 stepIgnored(String message)
          The step is marked as ignored with a descriptive message.
 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 testFailed(TestOutcome testOutcome, Throwable cause)
          The test failed, but not while executing a step.
 void testFinished(TestOutcome result)
          A test has finished.
 void testIgnored()
          The test as a whole was skipped or ignored.
 void testStarted(String testMethod)
          An individual test starts.
 void testSuiteFinished()
          End of a test case or story.
 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.
 
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(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,
                        Configuration configuration)

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

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

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.

testFinished

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

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

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

stepIgnored

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

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

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


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