-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Purpose
- コードの品質を保証し、リファクタリングや機能追加時の回帰を防ぐ。
- テスト駆動開発(TDD)の基盤を整備する。
AsIs
- テストコードが存在しない
- テストフレームワーク(pytest等)が依存関係に含まれていない
- テスト用の設定やフィクスチャがない
- CI/CDでのテスト実行がない
- 手動での動作確認のみ
- コード変更時の影響範囲が不明確
- リファクタリング時の安全性が低い
ToBe
- pytestを使用したテストフレームワークの導入
- ユニットテスト(Domain Layer、Application Layer)
- 統合テスト(APIエンドポイント、データベース連携)
- E2Eテスト(主要なユーザーフロー)
- テストカバレッジの目標設定(80%以上)
- CI/CDでの自動テスト実行
# tests/unit/domain/test_conversation.py
def test_conversation_validation():
with pytest.raises(ValueError):
Conversation(id=None, user_id="", session_id="", message="")
# tests/integration/test_chat_api.py
async def test_send_message(client):
response = await client.post("/api/chat/send", json={
"message": "こんにちは",
"session_id": "sess_123"
})
assert response.status_code == 200Remarks
pytest、pytest-asyncio、httpxを使用- テスト用のデータベース設定(テスト専用のPostgreSQL、Redis)
- モックの活用(外部API、データベース)
- テストフィクスチャの作成
- テストデータの管理
- カバレッジレポートの生成(
pytest-cov)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request