LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
testing::TesterEnvironment< ConfigurationClass > Class Template Reference

A test environment with some support for service providers. More...

#include "unit_test_base.h"

Inheritance diagram for testing::TesterEnvironment< ConfigurationClass >:
testing::BasicTesterEnvironment< ConfigurationClass >

Public Types

using Configuration_t = ConfigurationClass
 

Public Member Functions

template<typename Prov , typename... Args>
Prov * SetupProvider (Args &&...args)
 Sets a service provider up by calling its testing::setupProvider() More...
 
template<typename Prov , typename... Args>
Prov * SetupProviderFromService (std::string name, Args &&...args)
 Sets a service provider up by calling its testing::setupProvider() More...
 
template<typename Prov >
Prov * AcquireProvider (std::unique_ptr< Prov > &&prov)
 Acquires a service provider. More...
 
template<typename Interface , typename Prov , typename... Args>
Prov * SetupProviderFor (Args &&...args)
 Sets a provider up, recording it as implementation of Interface. More...
 
template<typename Interface , typename Prov , typename... Args>
Prov * SetupProviderFromServiceFor (std::string name, Args &&...args)
 Sets a provider up, recording it as implementation of Interface. More...
 
template<typename Interface , typename Prov >
Prov * AcquireProviderFor (std::unique_ptr< Prov > &&prov)
 Acquires a service provider implementing an interface. More...
 
template<typename Prov >
Prov * SimpleProviderSetup ()
 Oversimplified provider setup. More...
 
template<typename Prov >
void DropProvider ()
 Removes and destroys the specified provider. More...
 
template<typename Prov >
Prov const * Provider () const
 Return the specified provider (throws if not available) More...
 
template<typename... Provs>
void FillProviderPack (lar::ProviderPack< Provs... > &pack) const
 Fills the specified provider pack with providers. More...
 
template<typename Prov >
Prov::providers_type ProviderPackFor () const
 Returns a provider pack for the specified provider. More...
 
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...
 

Static Public Member Functions

static fhicl::ParameterSet CompileParameterSet (std::string cfg)
 Compiles a parameter set from a string. More...
 

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...
 
virtual void SetupMessageFacility (fhicl::ParameterSet const &pset, std::string appl_name="") const
 Sets up the message facility. More...
 
virtual void SetupMessageFacility () const
 Sets up the message facility. More...
 

Static Protected Member Functions

static fhicl::ParameterSet ParseParameters (std::string config_path)
 Fills the test configuration from file or from default. More...
 

Protected Attributes

ProviderList providers
 list of available providers More...
 

Private Types

using TesterEnvBase_t = BasicTesterEnvironment< ConfigurationClass >
 
using TesterEnv_t = TesterEnvironment< ConfigurationClass >
 

Detailed Description

template<typename ConfigurationClass>
class testing::TesterEnvironment< ConfigurationClass >

A test environment with some support for service providers.

Template Parameters
ConfigurationClassa class providing compile-time configuration

This test environment extends BasicTesterEnvironment with some basic support for service providers.

Service provider support

This environment makes it available the method Provider<Prov>(), which returns a pointer to the provider of type Prov.

All providers must be set up after the test environment is constructed. The environment provides the following facilities:

The set up methods support a For variant (e.g. SetupProviderFor()) to register the provider also under the type of its interface. For example, if LArPropertiesStandard is an implementation of LArProperties, the call:

env.SetupProviderFor<LArProperties, LArPropertiesStandard>(pset);

will set up a LArPropertiesStandard provider just like

env.SetupProvider<LArPropertiesStandard>(pset);

would, and it makes the provider available as LArProperties too, so that both calls:

env.Provider<LArProperties>();
env.Provider<LArPropertiesStandard>();

are valid and return the same provider.

Use as test fixture

The providers must be set up after the test environment is constructed. This also means an additional complication for fixtures that require to be constructed in a final state, as it is the case for Boost unit test suite fixtures. In these cases, a class should publicly derive from TesterEnvironment, and the necessary setup should be added into the constructor of this derived class.

Note that, as in the case of BasicTesterEnvironment, in this case there is no room for polymorphism here since the setup need to happen on construction.

Definition at line 747 of file unit_test_base.h.

Member Typedef Documentation

template<typename ConfigurationClass >
using testing::BasicTesterEnvironment< ConfigurationClass >::Configuration_t = ConfigurationClass
inherited

Definition at line 564 of file unit_test_base.h.

template<typename ConfigurationClass >
using testing::TesterEnvironment< ConfigurationClass >::TesterEnv_t = TesterEnvironment<ConfigurationClass>
private

Definition at line 751 of file unit_test_base.h.

template<typename ConfigurationClass >
using testing::TesterEnvironment< ConfigurationClass >::TesterEnvBase_t = BasicTesterEnvironment<ConfigurationClass>
private

Definition at line 750 of file unit_test_base.h.

Member Function Documentation

template<typename ConfigurationClass >
template<typename Prov >
Prov* testing::TesterEnvironment< ConfigurationClass >::AcquireProvider ( std::unique_ptr< Prov > &&  prov)
inline

Acquires a service provider.

Template Parameters
Provtype of provider
Parameters
provthe provider to be acquired
Returns
a pointer to the provider
See also
SetupProvider()
Exceptions
runtime_errorif the provider already exists

This method registers and takes ownership of the specified provider. It is similar to SetupProvider() except that user is in charge of the preliminary creation and setup of the provider.

Definition at line 814 of file unit_test_base.h.

815  {
816  if (!providers.acquire(std::move(prov)))
817  throw std::runtime_error("Provider already exists!");
818  return providers.getPointer<Prov>();
819  }
T const * getPointer(std::string label="") const
Retrieve the object of type T stored with the specified label.
Definition: ProviderList.h:358
bool acquire(std::unique_ptr< T > &&obj_ptr, std::string label="")
Registers and gets ownership of the specified object.
Definition: ProviderList.h:268
ProviderList providers
list of available providers
template<typename ConfigurationClass >
template<typename Interface , typename Prov >
Prov* testing::TesterEnvironment< ConfigurationClass >::AcquireProviderFor ( std::unique_ptr< Prov > &&  prov)
inline

Acquires a service provider implementing an interface.

Template Parameters
Provtype of provider
Interfacetype provider alias
Parameters
provthe provider to be acquired
Returns
a pointer to the provider
See also
SetupProviderFor(), AcquireProvider()

This method registers and takes ownership of the specified provider, like AcquireProvider() does. It also registers the provider as an implementation of Interface class, as SetupProviderFor does. It is similar to SetupProvider() except that user is in charge of the preliminar creation and setup of the provider.

Definition at line 888 of file unit_test_base.h.

889  {
890  auto prov_ptr = providers.acquire(prov);
891  providers.set_alias<Prov, Interface>();
892  return prov_ptr;
893  }
bool acquire(std::unique_ptr< T > &&obj_ptr, std::string label="")
Registers and gets ownership of the specified object.
Definition: ProviderList.h:268
ProviderList providers
list of available providers
bool set_alias(std::string alias_label="", std::string prov_label="")
Sets the Alias type as an alias of the Prov provider (with labels)
Definition: ProviderList.h:309
template<typename ConfigurationClass >
fhicl::ParameterSet testing::BasicTesterEnvironment< ConfigurationClass >::CompileParameterSet ( std::string  cfg)
staticinherited

Compiles a parameter set from a string.


Returns
a parameters set with the complete configuration

Definition at line 1086 of file unit_test_base.h.

References fhicl::make_ParameterSet(), and testing::BasicTesterEnvironment< ConfigurationClass >::ParseParameters().

Referenced by testing::BasicTesterEnvironment< ConfigurationClass >::~BasicTesterEnvironment().

1087  {
1088  fhicl::ParameterSet global_pset;
1089  fhicl::make_ParameterSet(cfg, global_pset);
1090  return global_pset;
1091  } // BasicTesterEnvironment<>::CompileParameterSet()
void make_ParameterSet(intermediate_table const &tbl, ParameterSet &ps)
template<typename ConfigurationClass >
Configuration_t const& testing::BasicTesterEnvironment< ConfigurationClass >::Config ( ) const
inlineprotectedinherited

Returns a read-only version of the configuration.

Definition at line 636 of file unit_test_base.h.

636 { return config; }
Configuration_t config
instance of the configurer
template<typename ConfigurationClass >
void testing::BasicTesterEnvironment< ConfigurationClass >::Configure ( )
protectedvirtualinherited

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 1136 of file unit_test_base.h.

References testing::BasicTesterEnvironment< ConfigurationClass >::SetupMessageFacility().

1136  {
1137  std::string config_path = config.ConfigurationPath();
1138  params = config_path.empty()?
1139  DefaultParameters(): ParseParameters(config_path);
1140  } // BasicTesterEnvironment::Configure()
fhicl::ParameterSet params
full configuration of the test
static fhicl::ParameterSet ParseParameters(std::string config_path)
Fills the test configuration from file or from default.
virtual fhicl::ParameterSet DefaultParameters() const
Creates a full configuration for the test.
Configuration_t config
instance of the configurer
template<typename ConfigurationClass >
virtual fhicl::ParameterSet testing::BasicTesterEnvironment< ConfigurationClass >::DefaultParameters ( ) const
inlineprotectedvirtualinherited

Creates a full configuration for the test.

Returns
a parameters set with the complete configuration

Definition at line 648 of file unit_test_base.h.

References lar::standalone::SetupMessageFacility().

649  { return CompileParameterSet(config.DefaultConfiguration()); }
Configuration_t config
instance of the configurer
static fhicl::ParameterSet CompileParameterSet(std::string cfg)
Compiles a parameter set from a string.
template<typename ConfigurationClass >
template<typename Prov >
void testing::TesterEnvironment< ConfigurationClass >::DropProvider ( )
inline

Removes and destroys the specified provider.

Template Parameters
Provtype of provider to be destroyed
Exceptions
runtime_errorif the provider was not present

Definition at line 916 of file unit_test_base.h.

917  {
918  if (!providers.erase<Prov>())
919  throw std::runtime_error("Provider not present!");
920  }
bool erase(std::string label="")
Drops the object with the specified type and label.
Definition: ProviderList.h:290
ProviderList providers
list of available providers
template<typename ConfigurationClass >
template<typename... Provs>
void testing::TesterEnvironment< ConfigurationClass >::FillProviderPack ( lar::ProviderPack< Provs... > &  pack) const
inline

Fills the specified provider pack with providers.

Exceptions
runtime_errorand everything provider() method can throw
See also
Provider()

Definition at line 933 of file unit_test_base.h.

References trkf::fill().

934  {
935  details::ProviderPackFiller
936  <TesterEnv_t, lar::ProviderPack<Provs...>, Provs...>
937  ::fill
938  (*this, pack);
939  } // FillProviderPack()
void fill(const art::PtrVector< recob::Hit > &hits, int only_plane)
Container for a list of pointers to providers.
Definition: ProviderPack.h:114
TesterEnvironment< ConfigurationClass > TesterEnv_t
template<typename ConfigurationClass >
fhicl::ParameterSet const& testing::BasicTesterEnvironment< ConfigurationClass >::Parameters ( ) const
inlineinherited

Returns the full configuration.

Definition at line 606 of file unit_test_base.h.

606 { return params; }
fhicl::ParameterSet params
full configuration of the test
template<typename ConfigurationClass >
fhicl::ParameterSet testing::BasicTesterEnvironment< ConfigurationClass >::ParseParameters ( std::string  config_path)
staticprotectedinherited

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


Parameters
config_pathfull path of the FHiCL configuration file
Returns
a parameters set with the complete configuration from the file

Definition at line 1102 of file unit_test_base.h.

References fhicl::make_ParameterSet(), and fhicl::parse_document().

Referenced by testing::BasicTesterEnvironment< ConfigurationClass >::CompileParameterSet().

1103  {
1104  // configuration file lookup policy
1105  char const* fhicl_env = getenv("FHICL_FILE_PATH");
1106  std::string search_path = fhicl_env? std::string(fhicl_env) + ":": ".:";
1107  details::FirstAbsoluteOrLookupWithDotPolicy policy(search_path);
1108 
1109  // parse a configuration file; obtain intermediate form
1111  fhicl::parse_document(config_path, policy, table);
1112 
1113  // translate into a parameter set
1114  fhicl::ParameterSet global_pset;
1115  fhicl::make_ParameterSet(table, global_pset);
1116 
1117  return global_pset;
1118  } // BasicTesterEnvironment<>::ParseParameters()
void make_ParameterSet(intermediate_table const &tbl, ParameterSet &ps)
void parse_document(std::string const &filename, cet::filepath_maker &maker, intermediate_table &result)
Definition: parse.cc:856
template<typename ConfigurationClass >
template<typename Prov >
Prov const* testing::TesterEnvironment< ConfigurationClass >::Provider ( ) const
inline

Return the specified provider (throws if not available)

Definition at line 924 of file unit_test_base.h.

925  { return providers.getPointer<Prov>(); }
T const * getPointer(std::string label="") const
Retrieve the object of type T stored with the specified label.
Definition: ProviderList.h:358
ProviderList providers
list of available providers
template<typename ConfigurationClass >
template<typename Prov >
Prov::providers_type testing::TesterEnvironment< ConfigurationClass >::ProviderPackFor ( ) const
inline

Returns a provider pack for the specified provider.

Template Parameters
Provtype of the provider
Exceptions
runtime_errorand everything provider() method can throw
See also
FillProviderPack()

The provider is required to have a providers_type type defined as an specialisation of lar::ProviderPack.

Definition at line 952 of file unit_test_base.h.

953  {
954  typename Prov::providers_type pack;
955  FillProviderPack(pack);
956  return pack;
957  } // ProviderPackFor()
void FillProviderPack(lar::ProviderPack< Provs... > &pack) const
Fills the specified provider pack with providers.
template<typename ConfigurationClass >
fhicl::ParameterSet testing::BasicTesterEnvironment< ConfigurationClass >::ServiceParameters ( std::string  service_name) const
inlineinherited

Returns the configuration of the specified service.

Definition at line 609 of file unit_test_base.h.

References fhicl::ParameterSet::get().

610  {
612  (config.ServiceParameterSetPath(service_name));
613  }
fhicl::ParameterSet params
full configuration of the test
Configuration_t config
instance of the configurer
T get(std::string const &key) const
Definition: ParameterSet.h:231
template<typename ConfigurationClass >
void testing::BasicTesterEnvironment< ConfigurationClass >::Setup ( )
protectedvirtualinherited

The complete initialization, ran at construction by default.

Definition at line 1185 of file unit_test_base.h.

References lar::standalone::SetupMessageFacility().

1186  {
1187 
1188  //
1189  // get the configuration
1190  //
1191  Configure();
1192 
1193  //
1194  // parse the options specific to the test environment
1195  //
1197 
1198  //
1199  // set up the message facility
1200  //
1202 
1203  //
1204  // Optionally print the configuration
1205  //
1206  {
1207  mf::LogInfo msg("Configuration");
1208  msg << "Complete configuration (";
1209  if (config.ConfigurationPath().empty()) msg << "default";
1210  else msg << "'" << config.ConfigurationPath() << "'";
1211  msg << "):\n" << Parameters().to_indented_string(1);
1212  }
1213 
1214 
1215  mf::LogInfo("Test") << config.ApplicationName() << " base setup complete.";
1216 
1217  } // BasicTesterEnvironment<>::Setup()
fhicl::ParameterSet const & Parameters() const
Returns the full configuration.
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
Configuration_t config
instance of the configurer
virtual void Configure()
Reads and translates the configuration.
void ParseEnvironmentOptions()
Parses the configuration, looking for the test environment options.
std::string to_indented_string() const
virtual void SetupMessageFacility() const
Sets up the message facility.
template<typename ConfigurationClass >
void testing::BasicTesterEnvironment< ConfigurationClass >::SetupMessageFacility ( fhicl::ParameterSet const &  pset,
std::string  appl_name = "" 
) const
protectedvirtualinherited

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 1151 of file unit_test_base.h.

References fhicl::ParameterSet::get_if_present(), LOG_TRACE, mf::SetApplicationName(), mf::SetContextIteration(), mf::SetContextSinglet(), mf::StartMessageFacility(), and fhicl::ParameterSet::to_indented_string().

1152  {
1153  fhicl::ParameterSet mf_pset;
1154 
1155  if
1156  (!pset.get_if_present(config.ServiceParameterSetPath("message"), mf_pset))
1157  {
1158  mf_pset
1159  = CompileParameterSet(config.DefaultServiceConfiguration("message"));
1160  std::cout << "Using default message facility configuration:\n"
1161  << mf_pset.to_indented_string(1) << std::endl;
1162  } // if no configuration is available
1163 
1164  mf::StartMessageFacility(mf_pset);
1165  if (!appl_name.empty()) mf::SetApplicationName(appl_name);
1166  mf::SetContextIteration("Initialization");
1167  if (options.MessageLevels) {
1168  std::cout << "Printing message levels in 'MessageFacility' category."
1169  << std::endl;
1170 
1171  mf::LogProblem("MessageFacility") << "Error messages are shown.";
1172  mf::LogPrint("MessageFacility") << "Warning messages are shown.";
1173  mf::LogVerbatim("MessageFacility") << "Info messages are shown.";
1174  mf::LogTrace("MessageFacility") << "Debug messages are shown.";
1175  LOG_TRACE("MessageFacility")
1176  << "LOG_TRACE/LOG_DEBUG messages are not compiled away.";
1177  } // if print message levels
1178  mf::LogInfo("MessageFacility") << "MessageFacility started.";
1179  mf::SetContextSinglet("main");
1180  } // BasicTesterEnvironment::SetupMessageFacility()
MaybeLogger_< ELseverityLevel::ELsev_info, true > LogVerbatim
Options_t options
options for the test environment
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
Configuration_t config
instance of the configurer
void SetContextIteration(string const &val)
MaybeLogger_< ELseverityLevel::ELsev_error, true > LogProblem
void StartMessageFacility(fhicl::ParameterSet const &pset, string const &applicationName)
std::string to_indented_string() const
bool MessageLevels
print message levels on screen
void SetContextSinglet(string const &val)
MaybeLogger_< ELseverityLevel::ELsev_success, true > LogTrace
static fhicl::ParameterSet CompileParameterSet(std::string cfg)
Compiles a parameter set from a string.
void SetApplicationName(string const &applicationName)
#define LOG_TRACE(id)
MaybeLogger_< ELseverityLevel::ELsev_warning, true > LogPrint
template<typename ConfigurationClass >
virtual void testing::BasicTesterEnvironment< ConfigurationClass >::SetupMessageFacility ( ) const
inlineprotectedvirtualinherited

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 655 of file unit_test_base.h.

References lar::standalone::SetupMessageFacility().

Referenced by testing::BasicTesterEnvironment< ConfigurationClass >::Configure().

656  { SetupMessageFacility(Parameters(), config.ApplicationName()); }
fhicl::ParameterSet const & Parameters() const
Returns the full configuration.
Configuration_t config
instance of the configurer
virtual void SetupMessageFacility() const
Sets up the message facility.
template<typename ConfigurationClass >
template<typename Prov , typename... Args>
Prov* testing::TesterEnvironment< ConfigurationClass >::SetupProvider ( Args &&...  args)
inline

Sets a service provider up by calling its testing::setupProvider()

Template Parameters
Provtype of provider
Argstype of arguments for the setup function
Parameters
argsarguments for the setup function
Returns
a pointer to the provider set up
Exceptions
runtime_errorif the provider already exists
See also
SetupProviderFor(), AcquireProvider()

A provider of type Prov is created, set up and recorded. Provider setup is delegated to testing::setupProvider function specific to the provider itself (that is, testing::setupProvider<Prov>(args...)) to which the setup arguments are forwarded. If the provider already exists, an exception is thrown.

Definition at line 773 of file unit_test_base.h.

References testing::details::CommandLineArguments::args.

774  {
775  if (!providers.setup<Prov>(std::forward<Args>(args)...))
776  throw std::runtime_error("Provider already exists!");
777  return providers.getPointer<Prov>();
778  }
T const * getPointer(std::string label="") const
Retrieve the object of type T stored with the specified label.
Definition: ProviderList.h:358
ProviderList providers
list of available providers
bool setup(Args &&...args)
Construct and register an object of type T with specified arguments.
Definition: ProviderList.h:252
template<typename ConfigurationClass >
template<typename Interface , typename Prov , typename... Args>
Prov* testing::TesterEnvironment< ConfigurationClass >::SetupProviderFor ( Args &&...  args)
inline

Sets a provider up, recording it as implementation of Interface.

Template Parameters
Interfacetype of provider interface being implemented
Provtype of provider
Argstype of arguments for the setup function
Parameters
argsarguments for the setup function
Returns
a pointer to the provider set up
See also
SetupProvider()

This method performs the same type of setup as SetupProvider(). In addition, it registers the provider as an implementation of Interface. This means that the provider can be obtained not only with provider<Prov>(), which returns a pointer to the actual class Prov, but also as provider<Interface>(), which returns a pointer to the base class Interface.

Definition at line 838 of file unit_test_base.h.

References testing::details::CommandLineArguments::args.

839  {
840  auto prov = SetupProvider<Prov>(std::forward<Args>(args)...);
841  providers.set_alias<Prov, Interface>();
842  return prov;
843  }
ProviderList providers
list of available providers
bool set_alias(std::string alias_label="", std::string prov_label="")
Sets the Alias type as an alias of the Prov provider (with labels)
Definition: ProviderList.h:309
template<typename ConfigurationClass >
template<typename Prov , typename... Args>
Prov* testing::TesterEnvironment< ConfigurationClass >::SetupProviderFromService ( std::string  name,
Args &&...  args 
)
inline

Sets a service provider up by calling its testing::setupProvider()

Template Parameters
Provtype of provider
Argstype of arguments for the setup function
Parameters
namethe service name (for configuration retrieval)
argsarguments for the setup function
Returns
a pointer to the provider set up
See also
SetupProvider()
Exceptions
runtime_errorif the provider already exists

A provider of type Prov is created, set up and recorded. Provider setup is attempted by constructing the provider with a parameter set from the registered configuration of service with specified name.

Definition at line 795 of file unit_test_base.h.

References testing::details::CommandLineArguments::args.

796  {
797  return SetupProvider<Prov>
798  (this->ServiceParameters(name, std::forward<Args>(args)...));
799  }
fhicl::ParameterSet ServiceParameters(std::string service_name) const
Returns the configuration of the specified service.
template<typename ConfigurationClass >
template<typename Interface , typename Prov , typename... Args>
Prov* testing::TesterEnvironment< ConfigurationClass >::SetupProviderFromServiceFor ( std::string  name,
Args &&...  args 
)
inline

Sets a provider up, recording it as implementation of Interface.

Template Parameters
Interfacetype of provider interface being implemented
Provtype of provider
Argstype of arguments for the setup function
Parameters
namethe service name (for configuration retrieval)
argsarguments for the setup function
Returns
a pointer to the provider set up
See also
SetupProviderFromService(), SetupProviderFor()
Exceptions
runtime_errorif the provider already exists

This method performs the same type of setup as SetupProviderFromService(). In addition, it registers the provider as an implementation of Interface. This means that the provider can be obtained not only with provider<Prov>(), which returns a pointer to the actual class Prov, but also as provider<Interface>(), which returns a pointer to the base class Interface.

Definition at line 865 of file unit_test_base.h.

References testing::details::CommandLineArguments::args.

866  {
867  auto* prov
868  = SetupProviderFromService<Prov>(name, std::forward<Args>(args)...);
869  providers.set_alias<Prov, Interface>();
870  return prov;
871  }
ProviderList providers
list of available providers
bool set_alias(std::string alias_label="", std::string prov_label="")
Sets the Alias type as an alias of the Prov provider (with labels)
Definition: ProviderList.h:309
template<typename ConfigurationClass >
template<typename Prov >
Prov* testing::TesterEnvironment< ConfigurationClass >::SimpleProviderSetup ( )
inline

Oversimplified provider setup.

Returns
a pointer to the provider
Template Parameters
Provprovider type

This is a one-step setup of the specified provider.

It is available only if Prov provider comes with an implementation of testing::SimpleEnvironmentSetupClass that explains how to set up an environment.

Definition at line 908 of file unit_test_base.h.

908 { return simpleEnvironmentSetup<Prov>(*this); }
template<typename ConfigurationClass >
fhicl::ParameterSet testing::BasicTesterEnvironment< ConfigurationClass >::TesterParameters ( std::string  test_name) const
inlineinherited

Returns the configuration of the specified test.

Definition at line 616 of file unit_test_base.h.

References fhicl::ParameterSet::get().

617  {
619  (config.TesterParameterSetPath(test_name));
620  }
fhicl::ParameterSet params
full configuration of the test
Configuration_t config
instance of the configurer
T get(std::string const &key) const
Definition: ParameterSet.h:231
template<typename ConfigurationClass >
fhicl::ParameterSet testing::BasicTesterEnvironment< ConfigurationClass >::TesterParameters ( ) const
inlineinherited

Returns the configuration of the main test (undefined if no main test)

Definition at line 623 of file unit_test_base.h.

624  {
625  if (config.MainTesterParameterSetName().empty()) return {};
626  else return TesterParameters(config.MainTesterParameterSetName());
627  }
Configuration_t config
instance of the configurer
fhicl::ParameterSet TesterParameters() const
Returns the configuration of the main test (undefined if no main test)

Member Data Documentation

template<typename ConfigurationClass >
ProviderList testing::TesterEnvironment< ConfigurationClass >::providers
protected

list of available providers

Definition at line 961 of file unit_test_base.h.


The documentation for this class was generated from the following file: