con un clic
adding-tests
// analyzing a change to determine what tests are needed and adding them to the test suite
// analyzing a change to determine what tests are needed and adding them to the test suite
extending yourself with a new reusable skill by interviewing the user
modifying build configuration to enable/disable variants, switch compilers or flags, or otherwise prepare for a build
reviewing a change for semantic correctness, simplicity, design consistency, and completeness
reviewing a git diff for small localized coding mistakes that can be fixed without high-level understanding
how to run make correctly to get a good build, and otherwise understand the build system
running tests at various levels from smoke tests to full suite to randomized tests
| name | adding-tests |
| description | analyzing a change to determine what tests are needed and adding them to the test suite |
This skill is for analyzing a code change and adding appropriate test coverage. It covers both unit tests and randomized/fuzz tests, ensuring that new functionality is tested and bug fixes include regression tests.
This skill involves a fair amount of work. Consider splitting it into pieces and running each piece as a subagent (e.g., one for analyzing test needs, one for writing unit tests, one for randomized tests). Keep each subagent focused on a moderate amount of work so it doesn't get lost or wander off track.
The output is either confirmation that tests were added (with details), or confirmation that no additional tests are needed.
Before starting the analysis, gather the following information (if running as a subagent, the invoking agent should provide these; otherwise, determine them yourself or ask the user):
Git range: The git command to get the diff (e.g., git diff master...HEAD).
Type of change: Is this a new feature, bug fix, refactor, or performance change?
Bug/issue reference (if applicable): For bug fixes, the issue number or description of what was broken.
Specific test requirements (optional): Any specific testing requirements the user has mentioned.
If invoking as a subagent, the prompt should include: "Analyze and add tests
for: . Get the diff using <git-command>. "
Get the diff using the command provided by the invoking agent:
Categorize the change:
Locate tests related to the changed code:
Foo.cpp → FooTests.cpp)# Find test files
find src -name "*Tests.cpp" | xargs grep -l "FunctionName"
LogSlowExecution wrapper that will flag any
long-running units of work on the IO serviceFor changes affecting:
Consider whether randomized testing is appropriate:
Find existing tests in the same area and follow their patterns. Common patterns in this codebase:
src/ alongside the code they test, in a test/
subdirectory.*Tests.cpp*TestUtils.cppsrc/testIf adding a fuzz target:
Report what was done:
## Tests Added
### Unit Tests
1. **src/ledger/LedgerManagerTests.cpp**: `processEmptyTransaction`
- Tests that empty transactions are rejected with appropriate error
- Regression test for issue #1234
2. **src/ledger/LedgerManagerTests.cpp**: `processTransactionWithMaxOps`
- Tests boundary condition at maximum operation count
### Randomized Tests
1. **src/fuzz/FuzzTransactionFrame.cpp**: Extended to cover new transaction type
- Added generation of the new transaction variant
## No Additional Tests Needed
[If applicable, explain why existing coverage is sufficient]
Summarize your work as follows:
If invoked as a subagent, pass this summary back to the invoking agent.