Skip to content

Commit eb31252

Browse files
committed
documentation on the node
1 parent 88721e9 commit eb31252

File tree

2 files changed

+79
-0
lines changed

2 files changed

+79
-0
lines changed

deep_test/DEVELOPING.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Developing deep_test
2+
3+
## Building
4+
5+
```bash
6+
colcon build --packages-select deep_test
7+
```
8+
9+
## Running Tests
10+
11+
```bash
12+
colcon test --packages-select deep_test
13+
colcon test-result --verbose
14+
```
15+
16+
## Adding New Features
17+
18+
### Test Fixtures
19+
This includes code that follows the definition of a fixture as per catch2.
20+
21+
1. Add header to `include/test_fixtures/`
22+
2. Add implementation to `src/` if needed
23+
3. Include in `include/deep_test/deep_test.hpp`
24+
25+
### Test Nodes
26+
This includes code that acts as helper ros nodes for testing. They should be inherently event-driven nodes (do not introduce arbitrary sleeps).
27+
28+
1. Add header to `include/test_nodes/`
29+
2. Include in main header
30+
3. Keep nodes header-only when possible
31+
32+
## CMake Function
33+
34+
The `add_deep_test()` function automatically:
35+
- Links Catch2::Catch2WithMain
36+
- Links ROS dependencies (rclcpp, rclcpp_lifecycle)
37+
- Configures ament test registration
38+
- Sets up JUnit XML output

deep_test/README.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# deep_test
2+
3+
A ROS 2 testing framework built on Catch2 that provides test fixtures and utilities for testing ROS nodes, services, and communication patterns.
4+
5+
## Features
6+
7+
- **TestExecutorFixture**: Manages ROS executor lifecycle for tests
8+
- **Test Nodes**: Pre-built nodes for testing publishers, subscribers, services, and clients
9+
- **CMake Integration**: Simple `add_deep_test()` function for creating tests
10+
- **Catch2 Integration**: Built on Catch2 for modern C++ testing
11+
12+
## Quick Start
13+
14+
```cpp
15+
#include <catch2/catch.hpp>
16+
#include <deep_test/deep_test.hpp>
17+
18+
TEST_CASE_METHOD(deep_ros::test::TestExecutorFixture, "My ROS Test", "[ros]") {
19+
auto node = std::make_shared<rclcpp::Node>("test_node");
20+
add_node(node);
21+
start_spinning();
22+
23+
// Your test code here as sections
24+
SECTION("My test") {
25+
REQUIRE(node->get_name() == "test_node");
26+
}
27+
}
28+
```
29+
30+
## CMake Usage
31+
32+
```cmake
33+
find_package(deep_test REQUIRED)
34+
35+
add_deep_test(my_test
36+
test/my_test.cpp
37+
LIBRARIES
38+
my_package::my_library
39+
std_msgs::std_msgs
40+
)
41+
```

0 commit comments

Comments
 (0)