org.stjs.testing.driver
Class JUnitSession

java.lang.Object
  extended by org.stjs.testing.driver.JUnitSession

public class JUnitSession
extends Object

Represents one session of unit testing that may span multiple tests in multiple classes, and performs startup and cleanup actions based on the JUnit lifecycle.

Since JUnit itself does not provide any easy way to hook into its lifecycle, this class relies on STJSTestDriverRunner to gather hints about the lifecyle. The lifecycle of the JUnitSession is the following:

  1. It starts when the first STJSTestDriverRunner is instantiated
  2. It ends when the JVM shuts down.
This lifecycle has been successfully tested again both Eclipses and maven-surefire-plugins test harnesses.

Author:
lordofthepigs

Method Summary
 List<Browser> getBrowsers()
           
 DriverConfiguration getConfig()
           
<T> T
getDependency(Class<T> depencencyType)
           
static JUnitSession getInstance()
           
 void runnerCompleted(STJSTestDriverRunner runner)
          Called when the specified runner has finished executing all of its tests.
 void runnerInstantiated(STJSTestDriverRunner runner)
          Called when a runner has been instantiated.
 void testCompleted(STJSTestDriverRunner runner, org.junit.runners.model.FrameworkMethod method, TestResultCollection result)
          Called after a JUnit test has been executed by all the browsers
 void testStarting(STJSTestDriverRunner runner, org.junit.runners.model.FrameworkMethod method)
          Called before a JUnit test is dispatched to the browsers.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static JUnitSession getInstance()

runnerInstantiated

public void runnerInstantiated(STJSTestDriverRunner runner)
                        throws org.junit.runners.model.InitializationError
Called when a runner has been instantiated. This method is expected to be called many times in a row right after the session has started, once per STJSTestDriverRunner. The first time this method is called, the HTTP server and the browsers are configured and started. This method counts the number of times it has been called.

Throws:
org.junit.runners.model.InitializationError

testStarting

public void testStarting(STJSTestDriverRunner runner,
                         org.junit.runners.model.FrameworkMethod method)
Called before a JUnit test is dispatched to the browsers.


testCompleted

public void testCompleted(STJSTestDriverRunner runner,
                          org.junit.runners.model.FrameworkMethod method,
                          TestResultCollection result)
Called after a JUnit test has been executed by all the browsers


runnerCompleted

public void runnerCompleted(STJSTestDriverRunner runner)
Called when the specified runner has finished executing all of its tests.


getConfig

public DriverConfiguration getConfig()

getBrowsers

public List<Browser> getBrowsers()

getDependency

public <T> T getDependency(Class<T> depencencyType)


Copyright © 2013. All Rights Reserved.