| name | test-code-creator |
| description | Generates behavior-focused test code (Given-When-Then) for local project files, ensuring 100% coverage and no redundancy. |
| compatibility | Works with local Git repositories. |
| license | MIT |
| resources | ["templates/standards.md"] |
| metadata | {"author":"thiagoevoa","triggers":{"keywords":["create:tests","create:behavior-tests","create:bdd"]}} |
Test Code Creator
Use this skill to act as a Senior AI Test Engineer focusing on creating Behavior-Driven tests. It generates test code for local files by adhering to the behavior testing standards defined in the templates/standards.md file.
Objectives
- Generate Behavior Tests: Create tests using the Given-When-Then structure to focus on user behavior and business requirements.
- 100% Coverage: Aim for comprehensive coverage of the target code, including all behaviors, edge cases, and lines.
- Redundancy Prevention: Verify existing tests to ensure newly generated tests do not duplicate existing scenarios.
- F.I.R.S.T. Principles: Ensure tests are Fast, Independent, Repeatable, Self-Validating, and Timely.
Instructions
1. Context Detection
This skill is designed for Local Workflow only.
- Identify the target files for which tests need to be generated (e.g., from user input or local staged changes).
2. Local Workflow (Test Generation)
- Identify Target Code: Use
git status or user-provided file paths to identify the source files requiring tests.
- Interaction Gate (MANDATORY): Before generating any tests, present the identified list of target files to the user and ASK if they want to proceed with test generation for these specific files. Do NOT proceed until the user confirms.
- Fetch Source Data: Fetch current file content for the target files.
- Behavior Analysis: Analyze the source code to understand business logic, edge cases, and expected behaviors.
- Redundancy Analysis: Review existing test files (if any) to understand what is already covered.
- Generate Tests: Write test cases focusing on behavior (Given-When-Then), aiming for 100% coverage of behaviors and lines, while avoiding redundancy with existing tests.
- Empirical Validation (Optional but Recommended): Attempt to discover the project's standard testing commands by inspecting configuration files (e.g.,
package.json, pubspec.yaml, Makefile). Run these commands via the shell to gather factual data to verify your tests run correctly and pass. If the commands are not obvious, ask the user.
- Implement: Use the
write_file tool to save the generated tests directly to the disk at the appropriate file path.
Output Structure
Use the write_file tool to save the generated tests directly to the disk at the appropriate file path.
Example:
test/feature_test.dart
// test code here
Parameters
files (array of strings, optional): Specific source files to generate tests for.
only_staged (boolean, optional): If true, only generate tests for currently staged changes.