Skip to content

Commit 85e3fe3

Browse files
committed
fix tests that were failing due to bad assumptions
1 parent cc77236 commit 85e3fe3

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

tests/CMakeLists.txt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,9 @@ set(BT_TESTS
3737
if(ament_cmake_FOUND)
3838

3939
find_package(ament_cmake_gtest REQUIRED)
40+
find_package(ament_cmake_gmock REQUIRED)
4041

41-
ament_add_gtest(${BTCPP_LIBRARY}_test ${BT_TESTS})
42+
ament_add_gmock(${BTCPP_LIBRARY}_test ${BT_TESTS})
4243
target_link_libraries(${BTCPP_LIBRARY}_test
4344
${TEST_DEPENDECIES}
4445
${ament_LIBRARIES})
@@ -53,7 +54,9 @@ else()
5354

5455
target_link_libraries(behaviortree_cpp_test
5556
GTest::gtest
56-
GTest::gtest_main)
57+
GTest::gtest_main
58+
GTest::gmock
59+
)
5760

5861
endif()
5962

tests/gtest_factory.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include <gtest/gtest.h>
2+
#include <gmock/gmock.h>
23
#include <filesystem>
34
#include <string>
45
#include <utility>
@@ -83,7 +84,7 @@ static const char* xml_text_subtree_part1 = R"(
8384
<BehaviorTree ID="MainTree">
8485
<Fallback name="root_selector">
8586
<SubTree ID="DoorClosedSubtree" />
86-
<Action ID="PassThroughWindow" />
87+
<Action ID="PassThroughDoor" />
8788
</Fallback>
8889
</BehaviorTree>
8990
</root> )";
@@ -94,11 +95,10 @@ static const char* xml_text_subtree_part2 = R"(
9495
<BehaviorTree ID="DoorClosedSubtree">
9596
<Sequence name="door_sequence">
9697
<Decorator ID="Inverter">
97-
<Action ID="IsDoorLocked" />
98+
<Action ID="IsDoorClosed" />
9899
</Decorator>
99100
<Action ID="OpenDoor" />
100101
<Action ID="PassThroughDoor" />
101-
<Action ID="CloseDoor" />
102102
</Sequence>
103103
</BehaviorTree>
104104
</root> )";
@@ -259,7 +259,7 @@ TEST(BehaviorTreeFactory, SubtreeParsingError)
259259
catch(const BT::RuntimeError& e)
260260
{
261261
std::string error_msg = e.what();
262-
EXPECT_TRUE(error_msg.find("line 36") != std::string::npos);
262+
EXPECT_THAT(error_msg, ::testing::HasSubstr("line 11"));
263263
}
264264
try
265265
{
@@ -269,7 +269,7 @@ TEST(BehaviorTreeFactory, SubtreeParsingError)
269269
catch(const BT::RuntimeError& e)
270270
{
271271
std::string error_msg = e.what();
272-
EXPECT_TRUE(error_msg.find("line 7") != std::string::npos);
272+
EXPECT_THAT(error_msg, ::testing::HasSubstr("line 5"));
273273
}
274274
}
275275

0 commit comments

Comments
 (0)