generated from wessel/boilerplate
docs: Update test documentation
- Changed directories to TNC (Tilmann Naming Convention) - Updated `DatabaseManager` with new IMU methods - Added `IMUDatabaseWriter` test documentation
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
# Config Manager Unit Tests
|
||||
|
||||
Unit tests for `ConfigManager` are implemented in `src/g2_2025_grade_calculator_pkg/test/ConfigManager.test.cpp` using Google Test and ROS2 test utilities. The tests use temporary TOML files to validate configuration loading and parsing functionality.
|
||||
Unit tests for `ConfigManager` are implemented in `src/g2_2025_imu_reader_pkg/test/ConfigManager.test.cpp` using Google Test and ROS2 test utilities. The tests use temporary TOML files to validate configuration loading and parsing functionality.
|
||||
|
||||
## Test Cases
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Database Manager Unit Tests
|
||||
|
||||
Unit tests for `DatabaseManager` are implemented in `src/g2_2025_grade_calculator_pkg/test/DatabaseManager.test.cpp` using Google Test and ROS2 test utilities. The tests are designed to work reliably whether a database connection is available or not, focusing on error handling and method behavior validation.
|
||||
Unit tests for `DatabaseManager` are implemented in `src/g2_2025_imu_reader_pkg/test/DatabaseManager.test.cpp` using Google Test and ROS2 test utilities. The tests are designed to work reliably whether a database connection is available or not, focusing on error handling and method behavior validation.
|
||||
|
||||
## Test Cases
|
||||
|
||||
@@ -22,42 +22,12 @@ Unit tests for `DatabaseManager` are implemented in `src/g2_2025_grade_calculato
|
||||
|
||||
**Description:** Verifies retrieval of pending student-course combinations that need exam results.
|
||||
|
||||
- **Test Action:** Call `queue_pending_combinations()`
|
||||
- **Expected Result:** Returns valid vector (empty if no database connection, populated if connected)
|
||||
- Test action: Call `store_imu_data(linear_x, linear_y, linear_z, ang_x, ang_y, ang_z)` without an active DB connection.
|
||||
- Expected result: Returns `false` and does not throw — method must check connection status before DB operations.
|
||||
|
||||
### 4. StoreExamResultTest
|
||||
### 4. CreateTablesNoCrash
|
||||
|
||||
**Description:** Tests exam result storage with graceful handling of connection states.
|
||||
Description: Verifies calling `create_tables()` without an active connection is safe.
|
||||
|
||||
- **Test Action:**
|
||||
- Student: `"TestStudent"`
|
||||
- Course: `"TestCourse"`
|
||||
- Grade: `85`
|
||||
- **Expected Result:** Returns `false` if no connection, `true` if connected and successful
|
||||
|
||||
### 5. EnrollStudentTest
|
||||
|
||||
**Description:** Tests student enrollment into courses.
|
||||
|
||||
- **Test Action:**
|
||||
- StudentCourse object with test data
|
||||
- **Expected Result:** Returns `false` if no connection, `true` if connected and successful
|
||||
|
||||
### 6. GetFinalGradeTest
|
||||
|
||||
**Description:** Tests final grade retrieval for non-existent student-course combinations.
|
||||
|
||||
- **Test Action:**
|
||||
- Student: `"NonExistentStudent"`
|
||||
- Course: `"NonExistentCourse"`
|
||||
- **Expected Result:** Returns `-1` (no results found or no connection)
|
||||
|
||||
### 7. StoreFinalResultTest
|
||||
|
||||
**Description:** Tests storing calculated final course results.
|
||||
|
||||
- **Test Action:**
|
||||
- StudentCourse object
|
||||
- Exam count: `3`
|
||||
- Final grade: `75`
|
||||
- **Expected Result:** Returns `false` if no connection, `true` if connected and successful
|
||||
- Test action: Call `create_tables()` on a manager that is not connected.
|
||||
- Expected result: No exception thrown; the function should be a no-op when no DB connection exists.
|
||||
|
||||
18
doc/tests/IMUDatabaseWriter.md
Normal file
18
doc/tests/IMUDatabaseWriter.md
Normal file
@@ -0,0 +1,18 @@
|
||||
# IMU Database Writer Unit Tests
|
||||
|
||||
Unit tests for `IMUDatabaseWriter` are implemented in `src/g2_2025_imu_reader_pkg/test/IMUDatabaseWriter.test.cpp` using Google Test and ROS2 test utilities. These tests validate that the node subscribes to the `imu_data` topic, receives IMU messages, and forwards parsed values to the `DatabaseManager` interface. Tests use dependency injection with a mock `DatabaseManager` to avoid requiring a real database connection.
|
||||
|
||||
## Test Cases
|
||||
|
||||
### 1. ConstructorTest
|
||||
|
||||
**Description:** Verifies that `IMUDatabaseWriter` can be constructed.
|
||||
|
||||
- **Test Action:** Create `IMUDatabaseWriter` node with a `MockDatabaseManager`
|
||||
- **Expected Result:** Node instance created successfully without exceptions
|
||||
|
||||
### 2. ReceivesAndForwardsIMU
|
||||
|
||||
**Description:** Tests that the node receives IMU messages on the `imu_data` topic and calls `store_imu_data(...)` on the injected database manager.
|
||||
|
||||
- **Expected Result:** Mock's `called_` flag is set to `true`, confirming the node forwarded the IMU data to the database manager
|
||||
Reference in New Issue
Block a user