Configuration.SetupConfigRule

public static class Configuration.SetupConfigRule extends Object
implements TestRule

TestRule to initialize static Configuration object for unit tests.

For example:

 @Rule public ResetConfigRule resetConfig = new ResetConfigRule(); 
 @Rule public SetupConfigRule setupConfig = SetupConfigRule.uninitialized(); 

 @Test public void testSomething() {
     Properties configProperties = new Properties();
     configProperties.put("config.key1", "value1");
     setupConfig.initConfig(configProperties);
     // do test code using initialized configuration
     ...
   }
 

Public Method Summary

Statement
apply(Statement base, Description description)
void
initConfig(Properties properties)
Initialize Configuration based on supplied Properties.
static Configuration.SetupConfigRule
uninitialized()
Factory method to get an instance of Configuration.SetupConfigRule.

Inherited Method Summary

Public Methods

public Statement apply (Statement base, Description description)

Parameters
base
description

public void initConfig (Properties properties)

Initialize Configuration based on supplied Properties.

Parameters
properties

public static Configuration.SetupConfigRule uninitialized ()

Factory method to get an instance of Configuration.SetupConfigRule.