MoveIt Pro Behavior
Core Behaviors for MoveIt Pro
test_behavior_without_context_input_port_not_set.hpp File Reference
#include <gmock/gmock.h>
#include <moveit_studio_behavior_interface/shared_resources_node.hpp>
#include <moveit_studio_behavior_interface/test_behavior.hpp>
#include <moveit_studio_common/test_utils/ros_test.hpp>
Include dependency graph for test_behavior_without_context_input_port_not_set.hpp:

Namespaces

 moveit_studio
 
 moveit_studio::test_utils
 

Macros

#define INSTANTIATE_BEHAVIOR_WITHOUT_CONTEXT_PORT_NOT_SET_TESTS_(behavior_class, input_port_setter_generator, output_port_setter_generator, pre_tick_code)
 
#define INSTANTIATE_SYNC_BEHAVIOR_WITHOUT_CONTEXT_PORT_NOT_SET_TESTS(behavior_class, input_port_setter_generator, output_port_setter_generator)
 Automatically instantiates tests for the "input Behavior port not set" situation for synchronous Behaviors without context. More...
 
#define INSTANTIATE_ASYNC_BEHAVIOR_WITHOUT_CONTEXT_PORT_NOT_SET_TESTS(behavior_class, input_port_setter_generator, output_port_setter_generator)
 Automatically instantiates tests for the "input Behavior port not set" situation for asynchronous Behaviors without context. More...
 

Macro Definition Documentation

◆ INSTANTIATE_ASYNC_BEHAVIOR_WITHOUT_CONTEXT_PORT_NOT_SET_TESTS

#define INSTANTIATE_ASYNC_BEHAVIOR_WITHOUT_CONTEXT_PORT_NOT_SET_TESTS (   behavior_class,
  input_port_setter_generator,
  output_port_setter_generator 
)
Value:
behavior_class, input_port_setter_generator, output_port_setter_generator, \
ASSERT_EQ(behavior().executeTick(), BT::NodeStatus::RUNNING) \
<< "Should you use INSTANTIATE_SYNC_BEHAVIOR_PORT_NOT_SET_TESTS instead?"; \
constexpr auto kPortNotSetTestsMaxTimeBehaviorIsInRunningStatus
Definition: test_behavior_input_port_not_set.hpp:17
#define INSTANTIATE_BEHAVIOR_WITHOUT_CONTEXT_PORT_NOT_SET_TESTS_(behavior_class, input_port_setter_generator, output_port_setter_generator, pre_tick_code)
Definition: test_behavior_without_context_input_port_not_set.hpp:22

Automatically instantiates tests for the "input Behavior port not set" situation for asynchronous Behaviors without context.

One test is generated for each Behavior input port.

Parameters
behavior_classClass of the behavior under test. It cannot have namespace qualifiers. If those are needed, please use a using statement in the test file.
input_port_setter_generatorA port setter map generator defining the expected input ports.
output_port_setter_generatorA port setter map generator defining the expected output ports.

◆ INSTANTIATE_BEHAVIOR_WITHOUT_CONTEXT_PORT_NOT_SET_TESTS_

#define INSTANTIATE_BEHAVIOR_WITHOUT_CONTEXT_PORT_NOT_SET_TESTS_ (   behavior_class,
  input_port_setter_generator,
  output_port_setter_generator,
  pre_tick_code 
)
Value:
class behavior_class##BehaviorInputPortNotSetTest \
: public ::moveit_studio::test_utils::RosTest, \
public ::testing::WithParamInterface<std::string> \
{ \
public: \
behavior_class##BehaviorInputPortNotSetTest() \
{ \
initBehavior(#behavior_class, input_port_setter_generator, output_port_setter_generator); \
} \
}; \
\
TEST_P(behavior_class##BehaviorInputPortNotSetTest, FailsIfPortNotSet) \
{ \
const std::string missing_port_name = GetParam(); \
for (const auto& [port_name, port_setter] : input_port_setter_generator()) \
{ \
if (port_name == missing_port_name || !port_setter) \
{ \
continue; \
} \
port_setter(blackboard(), port_name); \
} \
pre_tick_code; \
EXPECT_EQ(behavior().executeTick(), BT::NodeStatus::FAILURE); \
} \
\
INSTANTIATE_TEST_SUITE_P(UnsetPortTests, behavior_class##BehaviorInputPortNotSetTest, \
::testing::ValuesIn(::moveit_studio::test_utils::getPortIDs(input_port_setter_generator(), \
/*only_mandatory=*/true)));
Adds testing capabilities of Behaviors without context to any test fixture.
Definition: test_behavior.hpp:56
std::set< std::string > getPortIDs(const PortSetterMap &map, const bool only_mandatory)
Returns port IDs in a port setter map.
Definition: test_behavior_impl.hpp:115

◆ INSTANTIATE_SYNC_BEHAVIOR_WITHOUT_CONTEXT_PORT_NOT_SET_TESTS

#define INSTANTIATE_SYNC_BEHAVIOR_WITHOUT_CONTEXT_PORT_NOT_SET_TESTS (   behavior_class,
  input_port_setter_generator,
  output_port_setter_generator 
)
Value:
INSTANTIATE_BEHAVIOR_WITHOUT_CONTEXT_PORT_NOT_SET_TESTS_(behavior_class, input_port_setter_generator, \
output_port_setter_generator, )

Automatically instantiates tests for the "input Behavior port not set" situation for synchronous Behaviors without context.

One test is generated for each Behavior input port.

Parameters
behavior_classClass of the behavior under test. It cannot have namespace qualifiers. If those are needed, please use a using statement in the test file.
input_port_setter_generatorA port setter map generator defining the expected input ports.
output_port_setter_generatorA port setter map generator defining the expected output ports.