public class Unitils extends Object
TestContext and the
different Modules.
An instance of Unitils is configured with a certain configuration using the init(Properties) method. Normally,
only one instance of Unitils exists at any time. The default instance can be obtained using the getInstance() method.
This default instance can be set to a custom initialized instance or instance of a custom subclass using
setInstance(Unitils).
If not set, the singleton instance is initialized by default using initSingletonInstance(). This method uses
the ConfigurationLoader to load the configuration. An instance of ModulesRepository is used to
initialize and maintain the modules.
Unitils itself is also implemented as a module. In fact, an instance of Unitils behaves like a module who's behaviour
is defined by the added behaviour of all modules.| Constructor and Description |
|---|
Unitils()
Creates a new instance.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
afterInitModules()
Gives all modules the opportunity to performs initialization that
can only work after all other modules have been initialized
|
protected ModulesRepository |
createModulesRepository(Properties configuration)
Configures all unitils modules using the given
Properties object, and stores them in a ModulesRepository. |
Properties |
getConfiguration()
Returns all properties that are used to configure unitils and the different modules.
|
static Unitils |
getInstance()
Returns the singleton instance
|
ModulesRepository |
getModulesRepository()
Returns the
ModulesRepository that provides access to the modules that are configured in unitils. |
TestContext |
getTestContext()
Returns the
TestContext that, during the execution of the test suite, keeps track of the current test
object, class and test method that are executing. |
TestListener |
getTestListener()
Returns the single instance of
TestListener. |
void |
init()
Initializes unitils with the configuration files.
|
void |
init(Properties configuration)
Initializes Unitils with the given configuration.
|
static void |
initSingletonInstance()
Initializes the singleton instance to the default value, loading the configuration using the
ConfigurationLoader |
protected boolean |
isClassAvailable(String className)
Utility method that verifies whether the class with the given fully qualified classname is available
in the classpath.
|
static void |
setInstance(Unitils unitils)
Sets the singleton instance to the given object
|
protected void |
verifyPackaging(Properties configuration)
Verifies that we're not working with a distribution that includes the necessary classes from spring,
while spring is in the classpath anyway.
|
public static Unitils getInstance()
public static void setInstance(Unitils unitils)
unitils - the singleton instancepublic static void initSingletonInstance()
ConfigurationLoaderpublic void init()
public void init(Properties configuration)
configuration - The config, not nullprotected void afterInitModules()
protected void verifyPackaging(Properties configuration)
configuration - The configurationprotected boolean isClassAvailable(String className)
className - The name of the classpublic TestListener getTestListener()
TestListener. This instance provides hook callback methods that enable intervening
during the execution of unit tests.TestListenerpublic ModulesRepository getModulesRepository()
ModulesRepository that provides access to the modules that are configured in unitils.ModulesRepositorypublic TestContext getTestContext()
TestContext that, during the execution of the test suite, keeps track of the current test
object, class and test method that are executing.TestContextpublic Properties getConfiguration()
Properties objectprotected ModulesRepository createModulesRepository(Properties configuration)
Properties object, and stores them in a ModulesRepository. The configuration of the modules is delegated to a ModulesLoader instance.configuration - The config, not nullModulesRepositoryCopyright © 2016. All Rights Reserved.