java.lang.Object
org.junit.runner.Runner
org.junit.runners.ParentRunner<org.junit.runners.model.FrameworkMethod>
org.junit.runners.BlockJUnit4ClassRunner
net.serenitybdd.junit.runners.SerenityRunner
- All Implemented Interfaces:
net.thucydides.model.tags.Taggable,org.junit.runner.Describable,org.junit.runner.manipulation.Filterable,org.junit.runner.manipulation.Orderable,org.junit.runner.manipulation.Sortable
public class SerenityRunner
extends org.junit.runners.BlockJUnit4ClassRunner
implements net.thucydides.model.tags.Taggable
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
ConstructorsConstructorDescriptionSerenityRunner(Class<?> klass) SerenityRunner(Class<?> klass, net.thucydides.core.webdriver.WebDriverFactory webDriverFactory) SerenityRunner(Class<?> klass, net.thucydides.core.webdriver.WebDriverFactory webDriverFactory, net.thucydides.core.webdriver.DriverConfiguration configuration) SerenityRunner(Class<?> klass, net.thucydides.core.webdriver.WebDriverFactory webDriverFactory, net.thucydides.core.webdriver.DriverConfiguration configuration, net.thucydides.model.batches.BatchManager batchManager) SerenityRunner(Class<?> klass, net.thucydides.core.webdriver.WebdriverManager webDriverManager, net.thucydides.core.webdriver.DriverConfiguration configuration, net.thucydides.model.batches.BatchManager batchManager) SerenityRunner(Class<?> klass, net.thucydides.model.batches.BatchManager batchManager) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidprotected org.openqa.selenium.WebDriverdriverFor(org.junit.runners.model.FrameworkMethod method) protected voidprotected net.thucydides.model.batches.BatchManagerBatch Manager used for running tests in parallel batchesprotected net.thucydides.core.webdriver.DriverConfigurationThe Configuration class manages output directories and driver types.protected Collection<net.thucydides.model.reports.AcceptanceTestReporter> protected org.openqa.selenium.WebDriverprotected org.openqa.selenium.WebDrivernet.thucydides.core.pages.PagesgetPages()protected JUnitStepListenerThe Step Listener observes and records what happens during the execution of the test.List<net.thucydides.model.domain.TestOutcome> Find the current set of test outcomes produced by the test execution.protected JUnitStepListenerprotected JUnitStepListenerinitListenersUsing(net.thucydides.core.pages.Pages pageFactory) protected voidprotected voidinjectAnnotatedPagesObjectInto(Object testCase) Instantiates the @ManagedPages-annotated Pages instance using current WebDriver.protected voidinjectDriverInto(Object testCase) Instantiate the @Managed-annotated WebDriver instance with current WebDriver.protected voidinjectEnvironmentVariablesInto(Object testCase) protected voidinjectScenarioStepsInto(Object testCase) Instantiates the @ManagedPages-annotated Pages instance using current WebDriver.protected org.junit.runners.model.StatementmethodInvoker(org.junit.runners.model.FrameworkMethod method, Object test) Running a unit test, which represents a test scenario.protected voidvoidrun(org.junit.runner.notification.RunNotifier notifier) Runs the tests in the acceptance test case.protected voidrunChild(org.junit.runners.model.FrameworkMethod method, org.junit.runner.notification.RunNotifier notifier) protected voidsetStepListener(JUnitStepListener stepListener) voidsubscribeReporter(net.thucydides.model.reports.AcceptanceTestReporter reporter) To generate reports, different AcceptanceTestReporter instances need to subscribe to the listener.voiduseQualifier(String qualifier) Methods inherited from class org.junit.runners.BlockJUnit4ClassRunner
collectInitializationErrors, computeTestMethods, createTest, createTest, describeChild, getChildren, getTestRules, isIgnored, methodBlock, possiblyExpectingExceptions, rules, testName, validateConstructor, validateFields, validateInstanceMethods, validateNoNonStaticInnerClass, validateOnlyOneConstructor, validateTestMethods, validateZeroArgConstructor, withAfters, withBefores, withPotentialTimeoutMethods inherited from class org.junit.runners.ParentRunner
childrenInvoker, classBlock, classRules, createTestClass, filter, getDescription, getName, getRunnerAnnotations, getTestClass, order, runLeaf, setScheduler, sort, validatePublicVoidNoArgMethods, withAfterClasses, withBeforeClasses, withInterruptIsolationMethods inherited from class org.junit.runner.Runner
testCount
-
Constructor Details
-
SerenityRunner
- Throws:
org.junit.runners.model.InitializationError
-
SerenityRunner
public SerenityRunner(Class<?> klass, net.thucydides.core.webdriver.WebDriverFactory webDriverFactory) throws org.junit.runners.model.InitializationError - Throws:
org.junit.runners.model.InitializationError
-
SerenityRunner
public SerenityRunner(Class<?> klass, net.thucydides.core.webdriver.WebDriverFactory webDriverFactory, net.thucydides.core.webdriver.DriverConfiguration configuration) throws org.junit.runners.model.InitializationError - Throws:
org.junit.runners.model.InitializationError
-
SerenityRunner
public SerenityRunner(Class<?> klass, net.thucydides.core.webdriver.WebDriverFactory webDriverFactory, net.thucydides.core.webdriver.DriverConfiguration configuration, net.thucydides.model.batches.BatchManager batchManager) throws org.junit.runners.model.InitializationError - Throws:
org.junit.runners.model.InitializationError
-
SerenityRunner
public SerenityRunner(Class<?> klass, net.thucydides.model.batches.BatchManager batchManager) throws org.junit.runners.model.InitializationError - Throws:
org.junit.runners.model.InitializationError
-
SerenityRunner
public SerenityRunner(Class<?> klass, net.thucydides.core.webdriver.WebdriverManager webDriverManager, net.thucydides.core.webdriver.DriverConfiguration configuration, net.thucydides.model.batches.BatchManager batchManager) throws org.junit.runners.model.InitializationError - Throws:
org.junit.runners.model.InitializationError
-
-
Method Details
-
getPages
public net.thucydides.core.pages.Pages getPages() -
getConfiguration
protected net.thucydides.core.webdriver.DriverConfiguration getConfiguration()The Configuration class manages output directories and driver types. They can be defined as system values, or have sensible defaults.- Returns:
- the current configuration
-
getBatchManager
protected net.thucydides.model.batches.BatchManager getBatchManager()Batch Manager used for running tests in parallel batches- Returns:
- the current batch manager object
-
getOutputDirectory
-
subscribeReporter
public void subscribeReporter(net.thucydides.model.reports.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.- Parameters:
reporter- an implementation of the AcceptanceTestReporter interface.
-
useQualifier
-
run
public void run(org.junit.runner.notification.RunNotifier notifier) Runs the tests in the acceptance test case.- Overrides:
runin classorg.junit.runners.ParentRunner<org.junit.runners.model.FrameworkMethod>
-
generateReports
protected void generateReports() -
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.- Returns:
- the current step listener
-
setStepListener
-
initStepEventBus
protected void initStepEventBus() -
initListenersUsing
-
initListeners
-
runChild
protected void runChild(org.junit.runners.model.FrameworkMethod method, org.junit.runner.notification.RunNotifier notifier) - Overrides:
runChildin classorg.junit.runners.BlockJUnit4ClassRunner
-
additionalBrowserCleanup
protected void additionalBrowserCleanup() -
prepareBrowserForTest
protected void prepareBrowserForTest() -
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:
methodInvokerin classorg.junit.runners.BlockJUnit4ClassRunner
-
injectDriverInto
Instantiate the @Managed-annotated WebDriver instance with current WebDriver.- Parameters:
testCase- A Serenity-annotated test class
-
driverFor
protected org.openqa.selenium.WebDriver driverFor(org.junit.runners.model.FrameworkMethod method) -
injectScenarioStepsInto
Instantiates the @ManagedPages-annotated Pages instance using current WebDriver.- Parameters:
testCase- A Serenity-annotated test class
-
injectAnnotatedPagesObjectInto
Instantiates the @ManagedPages-annotated Pages instance using current WebDriver.- Parameters:
testCase- A Serenity-annotated test class
-
injectEnvironmentVariablesInto
-
getDriver
protected org.openqa.selenium.WebDriver getDriver() -
getDriver
-
getTestOutcomes
Find the current set of test outcomes produced by the test execution.- Returns:
- the current list of test outcomes
-
getDefaultReporters
- Returns:
- The default reporters applicable for standard test runs.
-