🛠️ TemporalPythonテスト
複雑な業務プロセスを自動的に実行するTemporalワーク
📺 まず動画で見る(YouTube)
▶ 【衝撃】最強のAIエージェント「Claude Code」の最新機能・使い方・プログラミングをAIで効率化する超実践術を解説! ↗
※ jpskill.com 編集部が参考用に選んだ動画です。動画の内容と Skill の挙動は厳密には一致しないことがあります。
📜 元の英語説明(参考)
Comprehensive testing approaches for Temporal workflows using pytest, progressive disclosure resources for specific testing scenarios.
🇯🇵 日本人クリエイター向け解説
複雑な業務プロセスを自動的に実行するTemporalワーク
※ jpskill.com 編集部が日本のビジネス現場向けに補足した解説です。Skill本体の挙動とは独立した参考情報です。
下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o temporal-python-testing.zip https://jpskill.com/download/3588.zip && unzip -o temporal-python-testing.zip && rm temporal-python-testing.zip
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/3588.zip -OutFile "$d\temporal-python-testing.zip"; Expand-Archive "$d\temporal-python-testing.zip" -DestinationPath $d -Force; ri "$d\temporal-python-testing.zip"
完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。
💾 手動でダウンロードしたい(コマンドが難しい人向け)
- 1. 下の青いボタンを押して
temporal-python-testing.zipをダウンロード - 2. ZIPファイルをダブルクリックで解凍 →
temporal-python-testingフォルダができる - 3. そのフォルダを
C:\Users\あなたの名前\.claude\skills\(Win)または~/.claude/skills/(Mac)へ移動 - 4. Claude Code を再起動
⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。
🎯 このSkillでできること
下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。
📦 インストール方法 (3ステップ)
- 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
- 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
- 3. 展開してできたフォルダを、ホームフォルダの
.claude/skills/に置く- · macOS / Linux:
~/.claude/skills/ - · Windows:
%USERPROFILE%\.claude\skills\
- · macOS / Linux:
Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。
詳しい使い方ガイドを見る →- 最終更新
- 2026-05-17
- 取得日時
- 2026-05-17
- 同梱ファイル
- 1
💬 こう話しかけるだけ — サンプルプロンプト
- › Temporal Python Testing を使って、最小構成のサンプルコードを示して
- › Temporal Python Testing の主な使い方と注意点を教えて
- › Temporal Python Testing を既存プロジェクトに組み込む方法を教えて
これをClaude Code に貼るだけで、このSkillが自動発動します。
📖 Skill本文(日本語訳)
※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。
Temporal Python テスト戦略
pytest を使用した Temporal ワークフローの包括的なテストアプローチと、特定のテストシナリオに対応する段階的開示リソースです。
このスキルを使用しない場合
- タスクが Temporal Python のテスト戦略と無関係な場合
- この範囲外の異なるドメインやツールが必要な場合
指示
- 目標、制約、および必要な入力を明確にしてください。
- 関連するベストプラクティスを適用し、結果を検証してください。
- 実用的な手順と検証を提供してください。
- 詳細な例が必要な場合は、
resources/implementation-playbook.mdを開いてください。
このスキルを使用する場合
- ワークフローの単体テスト - タイムスキップによる高速テスト
- 統合テスト - モックされたアクティビティを含むワークフロー
- リプレイテスト - 本番履歴に対する決定論の検証
- ローカル開発 - Temporal サーバーと pytest のセットアップ
- CI/CD 統合 - 自動テストパイプライン
- カバレッジ戦略 - 80%以上のテストカバレッジの達成
テスト哲学
推奨アプローチ (出典: docs.temporal.io/develop/python/testing-suite):
- 大多数を統合テストとして記述する
- 非同期フィクスチャで pytest を使用する
- タイムスキップにより高速フィードバックが可能 (数ヶ月かかるワークフローが数秒に)
- ワークフローロジックを分離するためにアクティビティをモックする
- リプレイテストで決定論を検証する
3つのテストタイプ:
- 単体: タイムスキップ付きワークフロー、ActivityEnvironment 付きアクティビティ
- 統合: モックされたアクティビティ付きワーカー
- エンドツーエンド: 実際の Temporal サーバーと実際のアクティビティ (控えめに使用)
利用可能なリソース
このスキルは、段階的開示を通じて詳細なガイダンスを提供します。テストのニーズに基づいて特定のリソースをロードしてください。
単体テストリソース
ファイル: resources/unit-testing.md
ロードするタイミング: 個々のワークフローまたはアクティビティを単独でテストする場合
内容:
- タイムスキップ付き WorkflowEnvironment
- アクティビティテスト用の ActivityEnvironment
- 長時間実行されるワークフローの高速実行
- 手動の時間進行パターン
- pytest フィクスチャとパターン
統合テストリソース
ファイル: resources/integration-testing.md
ロードするタイミング: モックされた外部依存関係を持つワークフローをテストする場合
内容:
- アクティビティのモック戦略
- エラー注入パターン
- 複数アクティビティワークフローのテスト
- シグナルとクエリのテスト
- カバレッジ戦略
リプレイテストリソース
ファイル: resources/replay-testing.md
ロードするタイミング: 決定論を検証する場合、またはワークフローの変更をデプロイする場合
内容:
- 決定論の検証
- 本番履歴のリプレイ
- CI/CD 統合パターン
- バージョン互換性テスト
ローカル開発リソース
ファイル: resources/local-setup.md
ロードするタイミング: 開発環境をセットアップする場合
内容:
- Docker Compose 設定
- pytest のセットアップと設定
- カバレッジツールの統合
- 開発ワークフロー
クイックスタートガイド
基本的なワークフローテスト
import pytest
from temporalio.testing import WorkflowEnvironment
from temporalio.worker import Worker
@pytest.fixture
async def workflow_env():
env = await WorkflowEnvironment.start_time_skipping()
yield env
await env.shutdown()
@pytest.mark.asyncio
async def test_workflow(workflow_env):
async with Worker(
workflow_env.client,
task_queue="test-queue",
workflows=[YourWorkflow],
activities=[your_activity],
):
result = await workflow_env.client.execute_workflow(
YourWorkflow.run,
args,
id="test-wf-id",
task_queue="test-queue",
)
assert result == expected
基本的なアクティビティテスト
from temporalio.testing import ActivityEnvironment
async def test_activity():
env = ActivityEnvironment()
result = await env.run(your_activity, "test-input")
assert result == expected_output
カバレッジターゲット
推奨カバレッジ (出典: docs.temporal.io ベストプラクティス):
- ワークフロー: 80%以上のロジックカバレッジ
- アクティビティ: 80%以上のロジックカバレッジ
- 統合: モックされたアクティビティによるクリティカルパス
- リプレイ: デプロイ前のすべてのワークフローバージョン
主要なテスト原則
- タイムスキップ - 数ヶ月かかるワークフローを数秒でテスト
- アクティビティのモック - ワークフローロジックを外部依存関係から分離
- リプレイテスト - デプロイ前に決定論を検証
- 高いカバレッジ - 本番ワークフローの目標は80%以上
- 高速フィードバック - 単体テストはミリ秒単位で実行
リソースの使用方法
必要なときに特定のリソースをロード:
- 「単体テストパターンを見せてください」→
resources/unit-testing.mdをロード - 「アクティビティをモックするにはどうすればよいですか?」→
resources/integration-testing.mdをロード - 「ローカルの Temporal サーバーをセットアップしてください」→
resources/local-setup.mdをロード - 「決定論を検証してください」→
resources/replay-testing.mdをロード
その他の参照資料
- Python SDK テスト: docs.temporal.io/develop/python/testing-suite
- テストパターン: github.com/temporalio/temporal/blob/main/docs/development/testing.md
- Python サンプル: github.com/temporalio/samples-python
制限事項
- このスキルは、タスクが上記で説明されている範囲と明確に一致する場合にのみ使用してください。
- 出力を、環境固有の検証、テスト、または専門家によるレビューの代わりとして扱わないでください。
- 必要な入力、権限、安全境界、または成功基準が不足している場合は、停止して明確化を求めてください。
📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開
Temporal Python Testing Strategies
Comprehensive testing approaches for Temporal workflows using pytest, progressive disclosure resources for specific testing scenarios.
Do not use this skill when
- The task is unrelated to temporal python testing strategies
- You need a different domain or tool outside this scope
Instructions
- Clarify goals, constraints, and required inputs.
- Apply relevant best practices and validate outcomes.
- Provide actionable steps and verification.
- If detailed examples are required, open
resources/implementation-playbook.md.
Use this skill when
- Unit testing workflows - Fast tests with time-skipping
- Integration testing - Workflows with mocked activities
- Replay testing - Validate determinism against production histories
- Local development - Set up Temporal server and pytest
- CI/CD integration - Automated testing pipelines
- Coverage strategies - Achieve ≥80% test coverage
Testing Philosophy
Recommended Approach (Source: docs.temporal.io/develop/python/testing-suite):
- Write majority as integration tests
- Use pytest with async fixtures
- Time-skipping enables fast feedback (month-long workflows → seconds)
- Mock activities to isolate workflow logic
- Validate determinism with replay testing
Three Test Types:
- Unit: Workflows with time-skipping, activities with ActivityEnvironment
- Integration: Workers with mocked activities
- End-to-end: Full Temporal server with real activities (use sparingly)
Available Resources
This skill provides detailed guidance through progressive disclosure. Load specific resources based on your testing needs:
Unit Testing Resources
File: resources/unit-testing.md
When to load: Testing individual workflows or activities in isolation
Contains:
- WorkflowEnvironment with time-skipping
- ActivityEnvironment for activity testing
- Fast execution of long-running workflows
- Manual time advancement patterns
- pytest fixtures and patterns
Integration Testing Resources
File: resources/integration-testing.md
When to load: Testing workflows with mocked external dependencies
Contains:
- Activity mocking strategies
- Error injection patterns
- Multi-activity workflow testing
- Signal and query testing
- Coverage strategies
Replay Testing Resources
File: resources/replay-testing.md
When to load: Validating determinism or deploying workflow changes
Contains:
- Determinism validation
- Production history replay
- CI/CD integration patterns
- Version compatibility testing
Local Development Resources
File: resources/local-setup.md
When to load: Setting up development environment
Contains:
- Docker Compose configuration
- pytest setup and configuration
- Coverage tool integration
- Development workflow
Quick Start Guide
Basic Workflow Test
import pytest
from temporalio.testing import WorkflowEnvironment
from temporalio.worker import Worker
@pytest.fixture
async def workflow_env():
env = await WorkflowEnvironment.start_time_skipping()
yield env
await env.shutdown()
@pytest.mark.asyncio
async def test_workflow(workflow_env):
async with Worker(
workflow_env.client,
task_queue="test-queue",
workflows=[YourWorkflow],
activities=[your_activity],
):
result = await workflow_env.client.execute_workflow(
YourWorkflow.run,
args,
id="test-wf-id",
task_queue="test-queue",
)
assert result == expected
Basic Activity Test
from temporalio.testing import ActivityEnvironment
async def test_activity():
env = ActivityEnvironment()
result = await env.run(your_activity, "test-input")
assert result == expected_output
Coverage Targets
Recommended Coverage (Source: docs.temporal.io best practices):
- Workflows: ≥80% logic coverage
- Activities: ≥80% logic coverage
- Integration: Critical paths with mocked activities
- Replay: All workflow versions before deployment
Key Testing Principles
- Time-Skipping - Month-long workflows test in seconds
- Mock Activities - Isolate workflow logic from external dependencies
- Replay Testing - Validate determinism before deployment
- High Coverage - ≥80% target for production workflows
- Fast Feedback - Unit tests run in milliseconds
How to Use Resources
Load specific resource when needed:
- "Show me unit testing patterns" → Load
resources/unit-testing.md - "How do I mock activities?" → Load
resources/integration-testing.md - "Setup local Temporal server" → Load
resources/local-setup.md - "Validate determinism" → Load
resources/replay-testing.md
Additional References
- Python SDK Testing: docs.temporal.io/develop/python/testing-suite
- Testing Patterns: github.com/temporalio/temporal/blob/main/docs/development/testing.md
- Python Samples: github.com/temporalio/samples-python
Limitations
- Use this skill only when the task clearly matches the scope described above.
- Do not treat the output as a substitute for environment-specific validation, testing, or expert review.
- Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.