Environment for a test. More...
#include <unit_test_base.h>
Classes | |
struct | Options_t |
Test environment options. More... | |
Public Types | |
using | Configuration_t = ConfigurationClass |
using | Configuration_t = ConfigurationClass |
Public Member Functions | |
BasicTesterEnvironment (bool bSetup=true) | |
Constructor: sets everything up and declares the test started. More... | |
virtual | ~BasicTesterEnvironment () |
Destructor: closing remarks. More... | |
BasicTesterEnvironment (bool bSetup=true) | |
Constructor: sets everything up and declares the test started. More... | |
virtual | ~BasicTesterEnvironment () |
Destructor: closing remarks. More... | |
BasicTesterEnvironment (Configuration_t const &cfg_obj, bool bSetup=true) | |
Setup from a configuration. More... | |
BasicTesterEnvironment (Configuration_t &&cfg_obj, bool bSetup=true) | |
Configuration retrieval | |
fhicl::ParameterSet const & | Parameters () const |
Returns the full configuration. More... | |
fhicl::ParameterSet | ServiceParameters (std::string service_name) const |
Returns the configuration of the specified service. More... | |
fhicl::ParameterSet | TesterParameters (std::string test_name) const |
Returns the configuration of the specified test. More... | |
fhicl::ParameterSet | TesterParameters () const |
Returns the configuration of the main test (undefined if no main test) More... | |
fhicl::ParameterSet const & | Parameters () const |
Returns the full configuration. More... | |
fhicl::ParameterSet | ServiceParameters (std::string service_name) const |
Returns the configuration of the specified service. More... | |
fhicl::ParameterSet | TesterParameters (std::string test_name) const |
Returns the configuration of the specified test. More... | |
fhicl::ParameterSet | TesterParameters () const |
Returns the configuration of the main test (undefined if no main test) More... | |
BasicTesterEnvironment (Configuration_t const &configurer, bool bSetup=true) | |
Setup from a configuration. More... | |
BasicTesterEnvironment (Configuration_t &&configurer, bool bSetup=true) | |
Static Public Member Functions | |
static fhicl::ParameterSet | CompileParameterSet (std::string cfg) |
Compiles a parameter set from a string. More... | |
static fhicl::ParameterSet | CompileParameterSet (std::string cfg) |
Protected Member Functions | |
Configuration_t const & | Config () const |
Returns a read-only version of the configuration. More... | |
virtual void | Setup () |
The complete initialization, ran at construction by default. More... | |
virtual void | Configure () |
Reads and translates the configuration. More... | |
virtual fhicl::ParameterSet | DefaultParameters () const |
Creates a full configuration for the test. More... | |
Configuration_t const & | Config () const |
Returns a read-only version of the configuration. More... | |
virtual void | Setup () |
The complete initialization, ran at construction by default. More... | |
virtual void | Configure () |
Reads and translates the configuration. More... | |
virtual fhicl::ParameterSet | DefaultParameters () const |
Creates a full configuration for the test. More... | |
virtual void | SetupMessageFacility (fhicl::ParameterSet const &pset, std::string appl_name="") const |
Sets up the message facility. More... | |
virtual void | SetupMessageFacility () const |
virtual void | SetupMessageFacility (fhicl::ParameterSet const &pset, std::string appl_name="") const |
Sets up the message facility. More... | |
virtual void | SetupMessageFacility () const |
Static Protected Member Functions | |
static fhicl::ParameterSet | ParseParameters (std::string config_path) |
Fills the test configuration from file or from default. More... | |
static fhicl::ParameterSet | ParseParameters (std::string config_path) |
Fills the test configuration from file or from default. More... | |
Private Member Functions | |
void | FillArgumentsFromCommandLine () |
void | ParseEnvironmentOptions () |
Parses the configuration, looking for the test environment options. More... | |
Private Member Functions inherited from testing::details::CommandLineArguments | |
CommandLineArguments () | |
Constructor: automatically parses from Boost arguments. More... | |
CommandLineArguments (int argc, char **argv) | |
Constructor: parses from specified arguments. More... | |
void | ParseArguments (int argc, char **argv) |
Parses arguments. More... | |
std::string | Executable () const |
Returns the name of the executable as started. More... | |
std::vector< std::string > const & | Arguments () const |
Returns the list of non-Boost-test arguments on the command line. More... | |
bool | hasArgument (size_t iArg) const |
Returns whether we have arguments up to the iArg-th (0-based) More... | |
std::string const & | Argument (size_t iArg) const |
Returns the value of the iArg-th (0-based; no range check!) More... | |
CommandLineArguments () | |
Constructor: automatically parses from Boost arguments. More... | |
CommandLineArguments (int argc, char **argv) | |
Constructor: parses from specified arguments. More... | |
void | ParseArguments (int argc, char **argv) |
Parses arguments. More... | |
std::string | Executable () const |
Returns the name of the executable as started. More... | |
std::vector< std::string > const & | Arguments () const |
Returns the list of non-Boost-test arguments on the command line. More... | |
bool | hasArgument (size_t iArg) const |
Returns whether we have arguments up to the iArg-th (0-based) More... | |
std::string const & | Argument (size_t iArg) const |
Returns the value of the iArg-th (0-based; no range check!) More... | |
Private Attributes | |
Configuration_t | config |
instance of the configurer More... | |
fhicl::ParameterSet | params |
full configuration of the test More... | |
Options_t | options |
options for the test environment More... | |
Environment for a test.
ConfigurationClass | a class providing compile-time configuration |
The test environment is set up on construction.
The environment provides:
This class or a derived one can be used as global fixture for unit tests.
Unfortunately Boost does not give any control on the initialization of the object, so everything must be ready to go as hard coded. The ConfigurationClass class tries to alleviate that. That is another, small static class that BasicTesterEnvironment uses to get its parameters.
The requirements for the ConfigurationClass are:
std::string ApplicationName()
: the application namestd::string ConfigurationPath()
: path to the configuration filestd::string MainTesterParameterSetName()
: name of the configuration of the main test (commodity)std::string DefaultTesterConfiguration()
returning a FHiCL string to be parsed to extract the default test configurationWhether the configuration comes from a file or from the two provided defaults, it is always expected within the parameter set paths: the default configuration must also contain that path.
Note that there is no room for polymorphism here since the setup happens on construction. Some methods are declared virtual in order to allow to tweak some steps of the set up, but it's not trivial to create a derived class that works correctly: the derived class must declare a new default constructor, and that default constructor must call the protected constructor (BasicTesterEnvironment<ConfigurationClass>(no_setup))
Definition at line 558 of file unit_test_base.h.
using testing::BasicTesterEnvironment< ConfigurationClass >::Configuration_t = ConfigurationClass |
Definition at line 561 of file unit_test_base.h.
using testing::BasicTesterEnvironment< ConfigurationClass >::Configuration_t = ConfigurationClass |
Definition at line 563 of file unit_test_base.h.
|
inline |
Constructor: sets everything up and declares the test started.
The configuration is from a default-constructed ConfigurationClass. This is suitable for use as Boost unit test fixture.
Definition at line 569 of file unit_test_base.h.
|
inline |
Setup from a configuration.
configurer | an instance of ConfigurationClass |
The configuration is from the specified configurer class.
This constructor allows to use a non-default-constructed configuration. This can't be used (at best of my knowledge) when using this class as Boost unit test fixture.
In the r-value-reference constructor, the configurer is moved.
Definition at line 584 of file unit_test_base.h.
|
inline |
Definition at line 587 of file unit_test_base.h.
|
virtual |
Destructor: closing remarks.
Definition at line 1054 of file unit_test_base.h.
|
inline |
Constructor: sets everything up and declares the test started.
bSetup | (default: true ) call Setup() after construction |
The configuration is from a default-constructed ConfigurationClass. This is suitable for use as Boost unit test fixture.
Definition at line 572 of file unit_test_base.h.
|
inline |
Setup from a configuration.
configurer | an instance of ConfigurationClass |
bSetup | (default: true ) call Setup() after construction |
The configuration is from the specified configurer class.
This constructor allows to use a non-default-constructed configuration. This can't be used (at best of my knowledge) when using this class as Boost unit test fixture.
In the r-value-reference constructor, the configurer is moved.
Definition at line 589 of file unit_test_base.h.
|
inline |
Definition at line 592 of file unit_test_base.h.
|
virtual |
Destructor: closing remarks.
|
static |
Compiles a parameter set from a string.
Definition at line 1068 of file unit_test_base.h.
|
static |
|
inlineprotected |
Returns a read-only version of the configuration.
Definition at line 630 of file unit_test_base.h.
|
inlineprotected |
Returns a read-only version of the configuration.
Definition at line 635 of file unit_test_base.h.
|
protectedvirtual |
Reads and translates the configuration.
Fills the configuration.
The complete configuration (message facility and services) is read and saved, hence accessible by Parameters() method.
The configuration file path is taken by default from the first argument of the test. If that first argument is not present or empty, the default configuration path is received from the configurer. If the configuration path is still empty, a hard-coded configuration is used; otherwise, the FHiCL file specified in that path is parsed and used as full configuration.
Definition at line 1122 of file unit_test_base.h.
|
protectedvirtual |
Reads and translates the configuration.
|
inlineprotectedvirtual |
Creates a full configuration for the test.
Definition at line 642 of file unit_test_base.h.
|
inlineprotectedvirtual |
Creates a full configuration for the test.
Definition at line 647 of file unit_test_base.h.
|
private |
|
inline |
Returns the full configuration.
Definition at line 600 of file unit_test_base.h.
|
inline |
Returns the full configuration.
Definition at line 605 of file unit_test_base.h.
|
private |
Parses the configuration, looking for the test environment options.
Definition at line 1221 of file unit_test_base.h.
|
staticprotected |
Fills the test configuration from file or from default.
Returns the configuration from a FHiCL file.
If a FHiCL configuration file is specified, the configuration of the test is read from it according to the parameter set path of the test. Otherwise, it is parsed from the default one provided by the configurer.Parses from file and returns a FHiCL data structure
config_path | full path of the FHiCL configuration file |
Definition at line 1085 of file unit_test_base.h.
|
staticprotected |
Fills the test configuration from file or from default.
If a FHiCL configuration file is specified, the configuration of the test is read from it according to the parameter set path of the test. Otherwise, it is parsed from the default one provided by the configurer.Parses from file and returns a FHiCL data structure
|
inline |
Returns the configuration of the specified service.
Definition at line 603 of file unit_test_base.h.
|
inline |
Returns the configuration of the specified service.
Definition at line 608 of file unit_test_base.h.
|
protectedvirtual |
The complete initialization, ran at construction by default.
Reimplemented in testing::GeometryTesterEnvironment< ConfigurationClass >, testing::GeometryTesterEnvironment< ConfigurationClass >, testing::GeometryTesterEnvironment< CRMGeometryConfiguration >, testing::GeometryTesterEnvironment< CRMGeometryConfiguration >, testing::GeometryTesterEnvironment< StandardGeometryConfiguration >, and testing::GeometryTesterEnvironment< StandardGeometryConfiguration >.
Definition at line 1168 of file unit_test_base.h.
|
protectedvirtual |
The complete initialization, ran at construction by default.
Reimplemented in testing::GeometryTesterEnvironment< ConfigurationClass >, testing::GeometryTesterEnvironment< ConfigurationClass >, testing::GeometryTesterEnvironment< CRMGeometryConfiguration >, testing::GeometryTesterEnvironment< CRMGeometryConfiguration >, testing::GeometryTesterEnvironment< StandardGeometryConfiguration >, and testing::GeometryTesterEnvironment< StandardGeometryConfiguration >.
|
protectedvirtual |
Sets up the message facility.
Sets the message facility up.
Message facility configuration is expected in "services.message" parameter set. If not there, the default configuration is used.
Definition at line 1137 of file unit_test_base.h.
|
inlineprotectedvirtual |
Definition at line 649 of file unit_test_base.h.
|
protectedvirtual |
Sets up the message facility.
|
inlineprotectedvirtual |
Definition at line 654 of file unit_test_base.h.
|
inline |
Returns the configuration of the specified test.
Definition at line 610 of file unit_test_base.h.
|
inline |
Returns the configuration of the specified test.
Definition at line 615 of file unit_test_base.h.
|
inline |
Returns the configuration of the main test (undefined if no main test)
Definition at line 617 of file unit_test_base.h.
|
inline |
Returns the configuration of the main test (undefined if no main test)
Definition at line 622 of file unit_test_base.h.
|
private |
instance of the configurer
Definition at line 664 of file unit_test_base.h.
|
private |
options for the test environment
Definition at line 675 of file unit_test_base.h.
|
private |
full configuration of the test
Definition at line 669 of file unit_test_base.h.