在 Manus 中运行任何 Skill
一键导入
一键导入
一键在 Manus 中运行任何 Skill
开始使用test-generation
星标6
分支0
更新时间2026年2月8日 20:08
Generate comprehensive test cases for code
安装
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
SKILL.md
readonly菜单
Generate comprehensive test cases for code
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Design RESTful APIs following best practices
Systematic bug investigation and root cause analysis
Review code quality, patterns, and best practices
Generate commit messages following conventional commits with scope detection
Generate and update technical documentation
Break down features into implementable tasks
| type | skill |
| name | Test Generation |
| description | Generate comprehensive test cases for code |
| skillSlug | test-generation |
| phases | ["E","V"] |
| generated | "2026-02-08T00:00:00.000Z" |
| status | filled |
| scaffoldVersion | 2.0.0 |
Use this skill when writing tests for Smart Farming use cases, utilities, or entities. The project uses pytest with pytest-describe for BDD-style structure and mock repositories for isolation.
src/app/core/use_cases/{domain}/tests/{use_case_name}_test.pysrc/app/core/commons/tests/{utility_name}_test.pysrc/app/core/use_cases/tests/mocks/import pytest
from core.use_cases.{domain}.{use_case_name} import {UseCaseClass}
from core.use_cases.tests.mocks.repositories import Mock{Domain}Repository
# import other mocks as needed
def describe_{use_case_name}():
@pytest.fixture
def mock_repository():
return Mock{Domain}Repository()
@pytest.fixture
def use_case(mock_repository):
return {UseCaseClass}(repository=mock_repository)
def should_succeed_when_valid_input(use_case, mock_repository):
# Arrange
# ... set up test data in mock repository
# Act
result = use_case.execute(params)
# Assert
assert result is not None
# ... specific assertions
def should_raise_error_when_invalid_input(use_case):
# Arrange & Act & Assert
with pytest.raises(ExpectedError):
use_case.execute(invalid_params)
def should_handle_empty_data(use_case, mock_repository):
# Test edge case with no data
result = use_case.execute(params)
assert result == expected_empty_result
Mocks are in-memory implementations of repository interfaces:
class MockPlantsRepository:
def __init__(self):
self._plants = []
def find_all(self):
return self._plants
def find_by_id(self, plant_id):
return next((p for p in self._plants if p.id == plant_id), None)
def create(self, plant):
self._plants.append(plant)
def update(self, plant):
self._plants = [p if p.id != plant.id else plant for p in self._plants]
def delete(self, plant_id):
self._plants = [p for p in self._plants if p.id != plant_id]
For each use case, generate tests for:
# All tests
pytest
# Specific domain
pytest src/app/core/use_cases/plants/tests/
# Specific test file
pytest src/app/core/use_cases/sensors_records/tests/create_sensor_record_test.py
# Verbose with output
pytest -v -s
# Stop on first failure
pytest -x
*_test.py naming conventiondescribe_ prefix for BDD-style groupingpytest.fixture