Instalar com Codex ou Claude Copie este prompt, cole no Codex, Claude ou outro assistente e deixe que ele revise a página da skill e instale para você.
Um comando direto ignora o prompt de revisão. Verifique a origem antes de executá-lo.
The language and testing framework will be auto-detected from the file extension and project structure.
Workflow
At the end of each phase, pause and wait for user input or confirmation to proceed
Phase 1: Initial Analysis
Detect language and testing conventions:
Determine language from file extension
Scan project to identify testing framework and conventions
Adapt all subsequent steps to use appropriate syntax and patterns for this language/framework
Read the implementation file to understand:
Public API (functions, methods, classes, interfaces)
Input parameters and their types
Internal state management
Dependencies and imported modules
Any referenced files in the same project (you may read these to understand context)
Locate the test file:
Search for corresponding test file using project conventions
If no test file exists, ask user if one should be created
Check for code coverage tools:
Look for coverage configuration in project (coverage config files, test scripts with coverage flags)
Common tools: coverage.py (Python), JaCoCo/Cobertura (Java), jest coverage/nyc/istanbul (JavaScript), SimpleCov (Ruby), go test -cover (Go)
If coverage tool exists, run it to get baseline coverage report
Note current coverage percentages and uncovered lines/branches
This will help identify gaps in Phase 2
Read existing tests to understand:
Current test coverage across different types:
Statement coverage: Which lines of code are executed
Decision/branch coverage: Which if/else branches are taken
Condition coverage: Each boolean sub-expression (true/false)
Loop coverage: Zero iterations, one iteration, multiple iterations, maximum iterations
Expression evaluation coverage: Short-circuit evaluation in complex expressions (&&, ||)
Testing patterns and assertion syntax used
Mock/stub strategies
Test organization (suite grouping, setup patterns)
Existing edge cases covered
Check for project-specific testing guidelines:
Look for README.md, README.txt, CONTRIBUTING.md, CONTRIBUTING.txt in project root
If found, scan for architecture-specific testing patterns (e.g., hexagonal architecture, frontend patterns, mocking strategies)
Adapt all subsequent testing to follow project conventions
Ask user about additional context:
"Are there any additional files I should review (e.g., requirements docs, roadmaps, design docs)?"
STOP and wait for an answer
If user provides file paths, read and analyze them
Phase 2: Gap Analysis
Evaluate missing test coverage by analyzing what's currently tested vs what should be tested. Review the Common Edge Case Checklist (at end of document) and identify gaps in:
List missing test categories with specific examples
STOP and ask the user if all tests should be implemented, or if the user wants to skip some of them
Clarify undecided behaviour:
For any identified gaps with unclear expected behaviour, prompt the user to explain or decide the expected behaviour so you can use it in the next phase
Phase 3: Iterative Test Implementation
Write tests one at a time:
Pick highest priority test from the list
Add gap tests to existing test suites based on the flow or method they are testing
Write a single test (or small group of 2-3 related tests)
Name test to describe the outcome, not the action:
Format: "returns X when Y", "throws error when Z"
GOOD: "returns chunks without error when text contains newlines"
BAD: "handles newline characters"
CRITICAL: Ensure assertions match the test title
If testing "allows creating objects with different properties", assert the actual property values
If testing "preserves order", check the actual order of elements
If testing "applies transformation X", verify the transformation result directly
Avoid indirect checks (e.g., checking length when you should check actual values)
Use complete equality assertions with full expected values
Avoid partial string matching for short strings - check whole output
Follow arrange-act-assert structure clearly
Run the test immediately
Handle test failures:
If test fails, analyze the actual vs expected output
Determine if:
Test expectation is wrong: Update test to match actual behavior
Bug discovered: Create skipped test with bug documentation
Need more context: Try 2 more variations with different approaches
When you discover something surprising:
Explore the surrounding territory with additional tests
Bugs often cluster together - test similar scenarios
Try variations of the same input pattern
Test inverse/opposite operations
Document bugs in skipped tests:
Use framework's skip/ignore mechanism
Mark test name with "- BUG" suffix
Include comprehensive comment with:
Brief description of what's broken
Root cause analysis
Code location (file path and line number)
Current problematic code snippet
Proposed fix with code
Expected vs actual output
Keep the failing assertion in the test body
When a bug is discovered:
Try to create a minimal reproduction test
Isolate the bug to the smallest possible test case
If the bug seems to be in a dependency/nested component:
Create tests for that component (within the same project only)
Do NOT cross project boundaries to external dependencies
Write tests in the appropriate test file for that component
Ask yourself: "What's the simplest way to expose this bug?"
Document the minimal reproduction in the skipped test
DO NOT IMPLEMENT FIXES OR CHANGE THE IMPLEMENTATION FILE, ONLY WRITE TESTS
Maximum 3 attempts per test:
If can't get test passing in 3 tries, document and move on
Create skipped test with analysis
Continue with next test category
Mark progress after each passing test:
Confirm test passes
Move to next test in the list
Update user on progress
Ask the user if they want to perform advanced coverage:
STOP and ask the user for confirmation to proceed to additional tests in phase 4
Phase 4: Advanced Coverage
Use the Common Edge Case Checklist (at end of document) as your comprehensive reference for this phase. The checklist provides detailed examples and specific test cases organized by category.
Create a separate test suite inside the primary test file:
Check if "exploratory tests", "edge cases" or "bugmagnet session" test suite exists
If yes, use it
If not, create a new one with the name "bugmagnet session "
Add all tests created in phase 4 there, not in the primary test sections
Test complex interactions (if applicable):
See checklist: For Complex Interactions
Multiple features used together, three-way interactions, property/option precedence and override behavior
State changes across multiple operations, deep nesting, property conflicts
Test error handling comprehensively:
See checklist: For Error Conditions
Invalid property values with specific error messages, error context preservation (line numbers, file names)
Multiple errors in sequence, errors don't crash or prevent subsequent operations
Edge case inputs that should trigger errors (invalid types, out of range, malformed data)
Test numeric edge cases (where applicable):
See checklist: For Functions Taking Numbers, For Size/Length Boundaries, For Currency/Financial Numbers
Zero (various representations and contexts), numbers close to zero, negative numbers, very large/small numbers
Special floating point values (NaN, Infinity), scientific notation, formatted numbers
32/64-bit boundaries, powers of 2
Currency: varying decimal places by currency, locale-specific formatting, rounding rules
Test date/time edge cases (where applicable):
See checklist: For Date/Time Values
Leap seconds, leap years (including century boundaries), invalid dates
You may read any files in the same project: To understand implementation
Do not read external dependencies: Stay within project boundaries
Read imported modules: To understand behavior and contracts
Read configuration files: To understand valid values and constraints
Example Test Patterns
Note: These examples use JavaScript/Jest syntax for illustration. Treat them as pseudo-code and adapt to your language and testing framework's conventions.
Basic Test (Good Assertions)
// BAD: Test says "sets username" but only checks object existstest('sets username correctly', () => {
const user = createUser({username: 'alice'});
expect(user).toBeDefined();
});
// GOOD: Actually checks the usernametest('sets username correctly', () => {
const user = createUser({username: 'alice'});
expect(user.username).toEqual('alice');
});
Testing Actual Values Not Just Counts
// BAD: Test says "creates items with different IDs" but only checks counttest('creates items with different IDs', () => {
const items = createMultipleItems(['a', 'b']);
expect(items.length).toEqual(2);
});
// GOOD: Actually verifies the IDs are differenttest('creates items with different IDs', () => {
const items = createMultipleItems(['a', 'b']);
expect(items[0].id).not.toEqual(items[1].id);
expect(items[0].name).toEqual('a');
expect(items[1].name).toEqual('b');
});
Boundary Condition Test
test('handles empty input correctly', () => {
const result = moduleUnderTest.operation('');
expect(result).toEqual(expectedOutputForEmptyString);
});
test('handles very long input', () => {
const longString = 'x'.repeat(10000);
const result = moduleUnderTest.operation(longString);
expect(result.length).toBeGreaterThan(0);
expect(result).not.toContain('error');
});
Exploring Bug Clusters
// You find this bug:
test.skip('fails to handle negative index - BUG', () => {
const result = moduleUnderTest.getItemAt(-1);
expect(result).toEqual(lastItem);
// Actual: undefined
});
// Explore similar territory:test('handles index zero', () => {
const result = moduleUnderTest.getItemAt(0);
expect(result).toEqual(firstItem);
});
test('handles index beyond array length', () => {
const result = moduleUnderTest.getItemAt(1000);
expect(result).toBeUndefined();
});
test('handles non-integer index', () => {
const result = moduleUnderTest.getItemAt(1.5);
expect(result).toEqual(secondItem); // or error?
});
Minimal Bug Reproduction
// Original complex test that exposed bug:
test.skip('complex scenario fails - BUG', () => {
setup();
operation1();
operation2();
const result = operation3();
expect(result).toEqual(expected); // Fails
});
// Minimal reproduction:
test.skip('operation3 returns wrong value - BUG', () => {
const result = operation3();
expect(result).toEqual(expected); // Fails// Actual: wrongValue// Even without operation1 and operation2, this fails
});
Numeric Edge Case Tests
test('handles zero correctly', () => {
const result = moduleUnderTest.calculate(0);
expect(result).toEqual(0);
});
test('handles negative numbers', () => {
const result = moduleUnderTest.calculate(-5);
expect(result).toEqual(expectedNegativeResult);
});
test('handles very large numbers', () => {
const result = moduleUnderTest.calculate(Number.MAX_SAFE_INTEGER);
expect(result).toBeDefined();
});
Collection Edge Cases
test('handles empty array', () => {
const result = moduleUnderTest.process([]);
expect(result).toEqual([]);
});
test('handles single element', () => {
const result = moduleUnderTest.process([item]);
expect(result.length).toEqual(1);
expect(result[0]).toEqual(expectedTransformedItem);
});
test('handles many elements', () => {
const manyItems = Array(100).fill(null).map((_, i) =>createItem(i));
const result = moduleUnderTest.process(manyItems);
expect(result.length).toEqual(100);
});
Error Test
test('reports error for invalid input', () => {
moduleUnderTest.operation('invalid');
const result = moduleUnderTest.getErrors();
expect(result.errors.length).toEqual(1);
expect(result.errors[0].message).toEqual('exact error message');
expect(result.errors[0].context).toEqual({line: 10});
});
Skipped Bug Test with Minimal Reproduction
test.skip('feature returns wrong value - BUG', () => {
/*
* BUG: Feature produces wrong output
*
* ROOT CAUSE: Wrong parameter used in calculation at line 42
*
* CODE LOCATION: src/module.js:42
*
* MINIMAL REPRODUCTION: Just call feature() with no setup
*
* CURRENT CODE:
* return calculate(param1, value);
*
* PROPOSED FIX:
* return calculate(param2, value);
*
* EXPECTED: "correct output"
* ACTUAL: "wrong output"
*/const result = moduleUnderTest.feature();
expect(result).toEqual('correct output');
// Actual: 'wrong output'
});
Output Format
Progress Updates
"Writing test 1/12: - "
"Test passed: "
"Test failed (attempt 2/3): "
"Skipped test: - Bug documented"
"Exploring bug cluster: trying "
Final Summary
## Test Coverage Summary
**Tests Added: X total**
- Category 1 (Y tests)
- Category 2 (Z tests)
**Final Count:**
- X passing tests
- Y skipped tests (bugs documented)
- Total: Z tests
**Bugs Discovered:**
1. Bug name - file.js:line
- Root cause: ...
- Fix: ...
- Minimal reproduction: ...
Common Edge Case Checklist
When analyzing a module, consider these common scenarios:
For Functions Taking Numbers
Zero (various representations: 0, 0.0, -0)
Zero in context (false/missing, timers at zero, counters at zero, display with 0 items, contextual data mapping to 0)
Numbers close to zero (0.0001, -0.0001)
Negative numbers
Very large numbers (approaching max values)
Very small numbers (close to zero, min values)
Special floating point values (if applicable: NaN, Infinity)
Non-integer values where integers expected
Numbers with lots of decimals vs numbers with no decimals
Scientific notation (1E-16, 1E+10)
Formatted numbers with separators: 1,000,000 or 1.000.000 (locale-dependent)
Objects with extra/missing properties, deeply nested objects
Test state transition edge cases (where applicable):
See checklist: For Stateful Operations
Repeating same action multiple times, sequential actions in reverse order
Sequential actions out of order/different order
Executing one action multiple times within a sequence
Test domain-specific edge cases (where applicable based on parameter types):
See checklist: For Functions Taking Names, For Functions Taking Email Addresses, For Functions Taking URLs, For Functions Taking Geographic Data, For User Input with Security Implications, For File Paths and File System Operations
Names: Single character, very long (35-64 chars), extremely long, punctuation, accents, non-Latin scripts, mononymic names, reserved words ("Null", "Test"), multiple middle names, fictional/brand names, name changes
Email addresses: Valid formats (subdomain, plus addressing, IP addresses), internationalized domains, invalid formats
Geographic data: Single-letter city names, very long place names (58+ chars), special characters, various postal code formats (3-10 digits), postal codes optional in some countries, format changes over time, regional differences
Security: SQL injection, XSS attempts, HTML injection, path traversal
File paths: Path length boundaries (260 Windows, 4096 Linux/Mac), special characters, reserved filenames, file existence, file system state (no space, read-only), file availability (locked, unavailable), file integrity (corrupted, empty), path separators
Test violated domain constraints (implicit assumptions):
See checklist: For Violated Domain Constraints (Implicit Assumptions)
Code often makes assumptions about data that aren't explicitly validated
Uniqueness violations: Duplicate IDs, usernames, keys where uniqueness assumed
Mandatory field violations: Required fields null/empty/missing, collections assumed non-empty