Spaces:
Running
Running
File size: 1,261 Bytes
81aa0b5 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | ---
name: test
description: Generate tests for the current code or a specific file
argument-hint: File path or test framework
---
# Test Generation
Target: $ARGUMENTS
Generate tests for the specified file or the current changes.
## Process
1. If a file path is given, `read_file` it. Otherwise use `bash` to get `git diff HEAD` and identify changed files.
2. Identify the test framework in use:
- Python: pytest (preferred), unittest
- JavaScript: vitest, jest, mocha
- Check `package.json` or `requirements.txt` for hints
3. Read existing tests in the `tests/` or `__tests__/` directory to match style.
4. Generate tests that cover:
- Happy path (typical usage)
- Edge cases (empty input, boundary values)
- Error cases (invalid input, network failures)
- Integration points (if applicable)
5. Write the test file to the appropriate location using `write_file`.
6. Run the tests with `bash` to verify they pass.
## Rules
- One test file per source file (e.g. `src/auth.py` → `tests/test_auth.py`)
- Use descriptive test names: `test_user_can_login_with_valid_credentials`
- Arrange-Act-Assert pattern
- Don't test the framework — test your code's behavior
- Mock external dependencies (network, filesystem, time) when flaky
|