Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions .claude/skills/write-fastdeploy-unittest/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# write-fastdeploy-unittest

A skill that guides AI agents to write CI-compliant unit tests for the FastDeploy project.

## Features

- Automatically selects the appropriate test pattern based on the code under test (pure logic / GPU kernel / offline inference / E2E serving)
- Follows FastDeploy CI classification rules (multi-GPU sequential vs single-GPU parallel)
- Meets the 80% diff coverage PR threshold
- Correctly uses port variables, log isolation, and resource cleanup per CI conventions

## Usage

### Basic — specify a source file

```
Use the write-fastdeploy-unittest skill to add unit tests for fastdeploy/cache_manager/transfer_factory/file_store/file_store.py
```

### From coverage report — paste the line directly

```
Use the write-fastdeploy-unittest skill to add unit tests for:

fastdeploy/model_executor/model_loader/default_loader.py 48 32 14 0 26% 37-38, 42, 46-52, 56-66, 69-97
```

The coverage report format is: `file_path Stmts Miss Branch BrMiss Cover% Missing_lines`. The agent will focus on the uncovered lines and write tests specifically targeting those branches.

The agent will automatically:
1. Read the target source file and analyze uncovered lines
2. Select the appropriate test pattern (Pattern 1-4)
3. Generate a test file in the corresponding `tests/` subdirectory
4. Run tests and verify coverage

## Test Pattern Quick Reference

| Pattern | Use Case | Dependencies |
|---------|----------|--------------|
| 1 — Pure Logic | config, utils, scheduler, router, etc. | No GPU; mock external deps |
| 2 — GPU Kernel | ops, layers, numerical computation | Requires GPU; `@pytest.mark.gpu` |
| 3 — Offline Inference | LLM API, model loading | Requires MODEL_PATH |
| 4 — E2E Serving | End-to-end HTTP serving | subprocess + ports |

## Key Conventions

- Test file naming: `test_<module>.py`
- Test class naming: `Test<Module>`
- Coverage verification: `python -m coverage run --source=<directory> -m pytest <test_file> && coverage report -m`
- The `--source` parameter must be a directory path, not a dotted module name

## Related Files

- [SKILL.md](SKILL.md) — Full skill instruction document
Loading
Loading