Helper class to write automated tests. It provides a convenient API to load a world file, step simulation and check entities and components. More...
#include <TestFixture.hh>
Public Member Functions | |
TestFixture (const ServerConfig &_config) | |
Constructor. More... | |
TestFixture (const std::string &_path) | |
Constructor. More... | |
virtual | ~TestFixture () |
Destructor. More... | |
TestFixture & | Finalize () |
Finalize all the functions and add fixture to server. Finalize must be called before running the server, otherwise none of the On* functions will be called. The OnConfigure callback is called immediately on finalize. More... | |
TestFixture & | OnConfigure (std::function< void(const Entity &_entity, const std::shared_ptr< const sdf::Element > &_sdf, EntityComponentManager &_ecm, EventManager &_eventMgr)> _cb) |
Wrapper around a system's pre-update callback. More... | |
TestFixture & | OnPostUpdate (std::function< void(const UpdateInfo &, const EntityComponentManager &)> _cb) |
Wrapper around a system's post-update callback. More... | |
TestFixture & | OnPreUpdate (std::function< void(const UpdateInfo &, EntityComponentManager &)> _cb) |
Wrapper around a system's pre-update callback. More... | |
TestFixture & | OnUpdate (std::function< void(const UpdateInfo &, EntityComponentManager &)> _cb) |
Wrapper around a system's update callback. More... | |
std::shared_ptr< gz::sim::Server > | Server () const |
Get pointer to underlying server. More... | |
Detailed Description
Helper class to write automated tests. It provides a convenient API to load a world file, step simulation and check entities and components.
Usage
// Load a world with a fixture gz::sim::TestFixture fixture("path_to.sdf");
// Register callbacks, for example: fixture.OnPostUpdate([&](const gz::sim::UpdateInfo &, const gz::sim::EntityComponentManager &_ecm) { // Add expectations here }).Finalize(); // Be sure to call finalize before running the server.
// Run the server fixture.Server()->Run(true, 1000, false);
Constructor & Destructor Documentation
◆ TestFixture() [1/2]
|
explicit |
Constructor.
- Parameters
-
[in] _path Path to SDF file.
◆ TestFixture() [2/2]
|
explicit |
Constructor.
- Parameters
-
[in] _config Server config file
◆ ~TestFixture()
|
virtual |
Destructor.
Member Function Documentation
◆ Finalize()
TestFixture& Finalize | ( | ) |
Finalize all the functions and add fixture to server. Finalize must be called before running the server, otherwise none of the On*
functions will be called. The OnConfigure
callback is called immediately on finalize.
◆ OnConfigure()
TestFixture& OnConfigure | ( | std::function< void(const Entity &_entity, const std::shared_ptr< const sdf::Element > &_sdf, EntityComponentManager &_ecm, EventManager &_eventMgr)> | _cb | ) |
Wrapper around a system's pre-update callback.
- Parameters
-
[in] _cb Function to be called every pre-update The _entity and _sdf will correspond to the world entity.
- Returns
- Reference to self.
◆ OnPostUpdate()
TestFixture& OnPostUpdate | ( | std::function< void(const UpdateInfo &, const EntityComponentManager &)> | _cb | ) |
Wrapper around a system's post-update callback.
- Parameters
-
[in] _cb Function to be called every post-update
- Returns
- Reference to self.
◆ OnPreUpdate()
TestFixture& OnPreUpdate | ( | std::function< void(const UpdateInfo &, EntityComponentManager &)> | _cb | ) |
Wrapper around a system's pre-update callback.
- Parameters
-
[in] _cb Function to be called every pre-update
- Returns
- Reference to self.
◆ OnUpdate()
TestFixture& OnUpdate | ( | std::function< void(const UpdateInfo &, EntityComponentManager &)> | _cb | ) |
Wrapper around a system's update callback.
- Parameters
-
[in] _cb Function to be called every update
- Returns
- Reference to self.
◆ Server()
std::shared_ptr<gz::sim::Server> Server | ( | ) | const |
Get pointer to underlying server.
The documentation for this class was generated from the following file: