net.thucydides.junit.runners
Class ThucydidesRunner

Package class diagram package ThucydidesRunner
java.lang.Object
  extended by org.junit.runner.Runner
      extended by org.junit.runners.ParentRunner<org.junit.runners.model.FrameworkMethod>
          extended by org.junit.runners.BlockJUnit4ClassRunner
              extended by net.thucydides.junit.runners.ThucydidesRunner
All Implemented Interfaces:
org.junit.runner.Describable, org.junit.runner.manipulation.Filterable, org.junit.runner.manipulation.Sortable

public class ThucydidesRunner
extends org.junit.runners.BlockJUnit4ClassRunner

A test runner for WebDriver-based web tests. This test runner initializes a WebDriver instance before running the tests in their order of appearance. At the end of the tests, it closes and quits the WebDriver instance.

The test runner will by default produce output in XML and HTML. This can extended by subscribing more reporter implementations to the test runner.

Author:
johnsmart

Constructor Summary
ThucydidesRunner(Class<?> klass)
          Creates a new test runner for WebDriver web tests.
ThucydidesRunner(Class<?> klass, BatchManager batchManager)
           
ThucydidesRunner(Class<?> klass, com.google.inject.Injector injector)
           
ThucydidesRunner(Class<?> klass, WebDriverFactory webDriverFactory)
           
ThucydidesRunner(Class<?> klass, WebDriverFactory webDriverFactory, Configuration configuration)
           
ThucydidesRunner(Class<?> klass, WebdriverManager webDriverManager, Configuration configuration, BatchManager batchManager)
           
 
Method Summary
protected  org.openqa.selenium.WebDriver driverFor(org.junit.runners.model.FrameworkMethod method)
           
protected  void generateReports()
           
protected  BatchManager getBatchManager()
          Batch Manager used for running tests in parallel batches
protected  Configuration getConfiguration()
          The getConfiguration().manages output directories and driver types.
protected  Collection<AcceptanceTestReporter> getDefaultReporters()
          The default reporters applicable for standard test runs.
protected  org.openqa.selenium.WebDriver getDriver()
           
protected  org.openqa.selenium.WebDriver getDriver(String driver)
           
 File getOutputDirectory()
           
 Pages getPages()
           
protected  JUnitStepListener getStepListener()
          The Step Listener observes and records what happens during the execution of the test.
 List<TestOutcome> getTestOutcomes()
           
protected  WebdriverManager getWebdriverManager()
           
protected  JUnitStepListener initListeners()
           
protected  JUnitStepListener initListenersUsing(Pages pageFactory)
           
protected  void initStepEventBus()
           
protected  void injectAnnotatedPagesObjectInto(Object testCase)
          Instantiates the @ManagedPages-annotated Pages instance using current WebDriver.
protected  void injectDriverInto(Object testCase, org.junit.runners.model.FrameworkMethod method)
          Instantiate the @Managed-annotated WebDriver instance with current WebDriver.
protected  void injectScenarioStepsInto(Object testCase)
          Instantiates the @ManagedPages-annotated Pages instance using current WebDriver.
protected  boolean isUniqueSession()
           
protected  org.junit.runners.model.Statement methodInvoker(org.junit.runners.model.FrameworkMethod method, Object test)
          Running a unit test, which represents a test scenario.
protected  void resetBroswerFromTimeToTime()
           
protected  boolean restartBrowserBeforeTest()
           
 void run(org.junit.runner.notification.RunNotifier notifier)
          Runs the tests in the acceptance test case.
protected  void runChild(org.junit.runners.model.FrameworkMethod method, org.junit.runner.notification.RunNotifier notifier)
           
protected  void setStepListener(JUnitStepListener stepListener)
           
 void subscribeReporter(AcceptanceTestReporter reporter)
          To generate reports, different AcceptanceTestReporter instances need to subscribe to the listener.
 void useQualifier(String qualifier)
           
 
Methods inherited from class org.junit.runners.BlockJUnit4ClassRunner
collectInitializationErrors, computeTestMethods, createTest, describeChild, getChildren, getTestRules, methodBlock, possiblyExpectingExceptions, rules, testName, validateConstructor, validateFields, validateInstanceMethods, validateNoNonStaticInnerClass, validateOnlyOneConstructor, validateTestMethods, validateZeroArgConstructor, withAfters, withBefores, withPotentialTimeout
 
Methods inherited from class org.junit.runners.ParentRunner
childrenInvoker, classBlock, classRules, filter, getDescription, getName, getRunnerAnnotations, getTestClass, runLeaf, setScheduler, sort, validatePublicVoidNoArgMethods, withAfterClasses, withBeforeClasses
 
Methods inherited from class org.junit.runner.Runner
testCount
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ThucydidesRunner

public ThucydidesRunner(Class<?> klass)
                 throws org.junit.runners.model.InitializationError
Creates a new test runner for WebDriver web tests.

Throws:
org.junit.runners.model.InitializationError - if some JUnit-related initialization problem occurred

ThucydidesRunner

public ThucydidesRunner(Class<?> klass,
                        com.google.inject.Injector injector)
                 throws org.junit.runners.model.InitializationError
Throws:
org.junit.runners.model.InitializationError

ThucydidesRunner

public ThucydidesRunner(Class<?> klass,
                        WebDriverFactory webDriverFactory)
                 throws org.junit.runners.model.InitializationError
Throws:
org.junit.runners.model.InitializationError

ThucydidesRunner

public ThucydidesRunner(Class<?> klass,
                        WebDriverFactory webDriverFactory,
                        Configuration configuration)
                 throws org.junit.runners.model.InitializationError
Throws:
org.junit.runners.model.InitializationError

ThucydidesRunner

public ThucydidesRunner(Class<?> klass,
                        BatchManager batchManager)
                 throws org.junit.runners.model.InitializationError
Throws:
org.junit.runners.model.InitializationError

ThucydidesRunner

public ThucydidesRunner(Class<?> klass,
                        WebdriverManager webDriverManager,
                        Configuration configuration,
                        BatchManager batchManager)
                 throws org.junit.runners.model.InitializationError
Throws:
org.junit.runners.model.InitializationError
Method Detail

getPages

public Pages getPages()

getConfiguration

protected Configuration getConfiguration()
The getConfiguration().manages output directories and driver types. They can be defined as system values, or have sensible defaults.


getBatchManager

protected BatchManager getBatchManager()
Batch Manager used for running tests in parallel batches


getOutputDirectory

public File getOutputDirectory()

subscribeReporter

public void subscribeReporter(AcceptanceTestReporter reporter)
To generate reports, different AcceptanceTestReporter instances need to subscribe to the listener. The listener will tell them when the test is done, and the reporter can decide what to do.


useQualifier

public void useQualifier(String qualifier)

run

public void run(org.junit.runner.notification.RunNotifier notifier)
Runs the tests in the acceptance test case.

Overrides:
run in class org.junit.runners.ParentRunner<org.junit.runners.model.FrameworkMethod>

generateReports

protected void generateReports()

getStepListener

protected JUnitStepListener getStepListener()
The Step Listener observes and records what happens during the execution of the test. Once the test is over, the Step Listener can provide the acceptance test outcome in the form of an TestOutcome object.


setStepListener

protected void setStepListener(JUnitStepListener stepListener)

initStepEventBus

protected void initStepEventBus()

initListenersUsing

protected JUnitStepListener initListenersUsing(Pages pageFactory)

initListeners

protected JUnitStepListener initListeners()

getWebdriverManager

protected WebdriverManager getWebdriverManager()

runChild

protected void runChild(org.junit.runners.model.FrameworkMethod method,
                        org.junit.runner.notification.RunNotifier notifier)
Overrides:
runChild in class org.junit.runners.BlockJUnit4ClassRunner

restartBrowserBeforeTest

protected boolean restartBrowserBeforeTest()

isUniqueSession

protected boolean isUniqueSession()

resetBroswerFromTimeToTime

protected void resetBroswerFromTimeToTime()

methodInvoker

protected org.junit.runners.model.Statement methodInvoker(org.junit.runners.model.FrameworkMethod method,
                                                          Object test)
Running a unit test, which represents a test scenario.

Overrides:
methodInvoker in class org.junit.runners.BlockJUnit4ClassRunner

injectDriverInto

protected void injectDriverInto(Object testCase,
                                org.junit.runners.model.FrameworkMethod method)
Instantiate the @Managed-annotated WebDriver instance with current WebDriver.


driverFor

protected org.openqa.selenium.WebDriver driverFor(org.junit.runners.model.FrameworkMethod method)

injectScenarioStepsInto

protected void injectScenarioStepsInto(Object testCase)
Instantiates the @ManagedPages-annotated Pages instance using current WebDriver.


injectAnnotatedPagesObjectInto

protected void injectAnnotatedPagesObjectInto(Object testCase)
Instantiates the @ManagedPages-annotated Pages instance using current WebDriver.


getDriver

protected org.openqa.selenium.WebDriver getDriver()

getDriver

protected org.openqa.selenium.WebDriver getDriver(String driver)

getTestOutcomes

public List<TestOutcome> getTestOutcomes()

getDefaultReporters

protected Collection<AcceptanceTestReporter> getDefaultReporters()
The default reporters applicable for standard test runs.



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