| name | add-tests |
| description | Generate test scaffolding for untested modules. Analyze public functions, identify test cases, and create comprehensive test coverage.
|
Add Tests Skill
Generate test scaffolding for untested modules in Panoptes.
Steps
-
Analyze the target module
- Read the source file
- Identify public functions and their signatures
- Note any complex logic or edge cases
-
Determine testable components
- Pure functions (no side effects)
- State transitions
- Type conversions
- Validation logic
- Filter/search functions
-
Generate test scaffolding
Add a #[cfg(test)] block at the end of the module:
#[cfg(test)]
mod tests {
use super::*;
fn create_test_item() -> ItemType {
}
#[test]
fn test_function_name_basic() {
let input = create_test_item();
let result = function_name(input);
assert_eq!(result, expected);
}
#[test]
fn test_function_name_edge_case() {
}
}
-
Test categories to include
- Happy path: Normal expected usage
- Edge cases: Empty inputs, boundaries, special values
- Error cases: Invalid inputs, error conditions
- State transitions: Before/after state changes
Panoptes-Specific Patterns
Testing State Navigation
#[test]
fn test_navigate_to_project() {
let mut state = AppState::default();
let project_id = uuid::Uuid::new_v4();
state.navigate_to_project(project_id);
assert_eq!(state.view, View::ProjectDetail(project_id));
assert_eq!(state.selected_branch_index, 0);
}
Testing Filters
#[test]
fn test_filter_empty_query() {
let items = create_test_items();
let filtered = filter_items(&items, "");
assert_eq!(filtered.len(), items.len());
}
#[test]
fn test_filter_case_insensitive() {
let items = create_test_items();
let filtered = filter_items(&items, "MAIN");
assert!(filtered.iter().any(|i| i.name == "main"));
}
Testing Enums
#[test]
fn test_event_type_roundtrip() {
for event_type in [EventType::A, EventType::B, EventType::C] {
let str_repr = event_type.as_str();
let parsed: EventType = str_repr.into();
assert_eq!(parsed, event_type);
}
}
Common Dependencies
Tests often need:
use tempfile::TempDir;
use uuid::Uuid;
Output
After running this skill, you should have:
- A
#[cfg(test)] module with tests
- Tests for all public functions
- Edge case coverage
- Verifiable assertions (not just
assert!(true))