[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill-4cd22092-8065-4709-98b0-b700dc919446":3,"$f7etYmdEOaMRbKXORCQBi_C7fHCIBaUIXZeihfFba-5o":43},{"id":4,"title":5,"description":6,"categoryId":7,"moduleId":8,"tags":9,"prompt":10,"icon":11,"source":12,"sourceUrl":13,"authorId":14,"authorName":15,"isPublic":16,"stars":17,"runs":18,"createdAt":19,"updatedAt":19,"module":20,"category":27,"packages":34},"4cd22092-8065-4709-98b0-b700dc919446","temporal-python-testing","使用pytest对时间工作流进行综合测试方法，针对特定测试场景的渐进式披露资源。","cat_coding_review","mod_coding","sickn33,coding","---\nname: temporal-python-testing\ndescription: \"Comprehensive testing approaches for Temporal workflows using pytest, progressive disclosure resources for specific testing scenarios.\"\nrisk: unknown\nsource: community\ndate_added: \"2026-02-27\"\n---\n\n# Temporal Python Testing Strategies\n\nComprehensive testing approaches for Temporal workflows using pytest, progressive disclosure resources for specific testing scenarios.\n\n## Do not use this skill when\n\n- The task is unrelated to temporal python testing strategies\n- You need a different domain or tool outside this scope\n\n## Instructions\n\n- Clarify goals, constraints, and required inputs.\n- Apply relevant best practices and validate outcomes.\n- Provide actionable steps and verification.\n- If detailed examples are required, open `resources\u002Fimplementation-playbook.md`.\n\n## Use this skill when\n\n- **Unit testing workflows** - Fast tests with time-skipping\n- **Integration testing** - Workflows with mocked activities\n- **Replay testing** - Validate determinism against production histories\n- **Local development** - Set up Temporal server and pytest\n- **CI\u002FCD integration** - Automated testing pipelines\n- **Coverage strategies** - Achieve ≥80% test coverage\n\n## Testing Philosophy\n\n**Recommended Approach** (Source: docs.temporal.io\u002Fdevelop\u002Fpython\u002Ftesting-suite):\n\n- Write majority as integration tests\n- Use pytest with async fixtures\n- Time-skipping enables fast feedback (month-long workflows → seconds)\n- Mock activities to isolate workflow logic\n- Validate determinism with replay testing\n\n**Three Test Types**:\n\n1. **Unit**: Workflows with time-skipping, activities with ActivityEnvironment\n2. **Integration**: Workers with mocked activities\n3. **End-to-end**: Full Temporal server with real activities (use sparingly)\n\n## Available Resources\n\nThis skill provides detailed guidance through progressive disclosure. Load specific resources based on your testing needs:\n\n### Unit Testing Resources\n\n**File**: `resources\u002Funit-testing.md`\n**When to load**: Testing individual workflows or activities in isolation\n**Contains**:\n\n- WorkflowEnvironment with time-skipping\n- ActivityEnvironment for activity testing\n- Fast execution of long-running workflows\n- Manual time advancement patterns\n- pytest fixtures and patterns\n\n### Integration Testing Resources\n\n**File**: `resources\u002Fintegration-testing.md`\n**When to load**: Testing workflows with mocked external dependencies\n**Contains**:\n\n- Activity mocking strategies\n- Error injection patterns\n- Multi-activity workflow testing\n- Signal and query testing\n- Coverage strategies\n\n### Replay Testing Resources\n\n**File**: `resources\u002Freplay-testing.md`\n**When to load**: Validating determinism or deploying workflow changes\n**Contains**:\n\n- Determinism validation\n- Production history replay\n- CI\u002FCD integration patterns\n- Version compatibility testing\n\n### Local Development Resources\n\n**File**: `resources\u002Flocal-setup.md`\n**When to load**: Setting up development environment\n**Contains**:\n\n- Docker Compose configuration\n- pytest setup and configuration\n- Coverage tool integration\n- Development workflow\n\n## Quick Start Guide\n\n### Basic Workflow Test\n\n```python\nimport pytest\nfrom temporalio.testing import WorkflowEnvironment\nfrom temporalio.worker import Worker\n\n@pytest.fixture\nasync def workflow_env():\n    env = await WorkflowEnvironment.start_time_skipping()\n    yield env\n    await env.shutdown()\n\n@pytest.mark.asyncio\nasync def test_workflow(workflow_env):\n    async with Worker(\n        workflow_env.client,\n        task_queue=\"test-queue\",\n        workflows=[YourWorkflow],\n        activities=[your_activity],\n    ):\n        result = await workflow_env.client.execute_workflow(\n            YourWorkflow.run,\n            args,\n            id=\"test-wf-id\",\n            task_queue=\"test-queue\",\n        )\n        assert result == expected\n```\n\n### Basic Activity Test\n\n```python\nfrom temporalio.testing import ActivityEnvironment\n\nasync def test_activity():\n    env = ActivityEnvironment()\n    result = await env.run(your_activity, \"test-input\")\n    assert result == expected_output\n```\n\n## Coverage Targets\n\n**Recommended Coverage** (Source: docs.temporal.io best practices):\n\n- **Workflows**: ≥80% logic coverage\n- **Activities**: ≥80% logic coverage\n- **Integration**: Critical paths with mocked activities\n- **Replay**: All workflow versions before deployment\n\n## Key Testing Principles\n\n1. **Time-Skipping** - Month-long workflows test in seconds\n2. **Mock Activities** - Isolate workflow logic from external dependencies\n3. **Replay Testing** - Validate determinism before deployment\n4. **High Coverage** - ≥80% target for production workflows\n5. **Fast Feedback** - Unit tests run in milliseconds\n\n## How to Use Resources\n\n**Load specific resource when needed**:\n\n- \"Show me unit testing patterns\" → Load `resources\u002Funit-testing.md`\n- \"How do I mock activities?\" → Load `resources\u002Fintegration-testing.md`\n- \"Setup local Temporal server\" → Load `resources\u002Flocal-setup.md`\n- \"Validate determinism\" → Load `resources\u002Freplay-testing.md`\n\n## Additional References\n\n- Python SDK Testing: docs.temporal.io\u002Fdevelop\u002Fpython\u002Ftesting-suite\n- Testing Patterns: github.com\u002Ftemporalio\u002Ftemporal\u002Fblob\u002Fmain\u002Fdocs\u002Fdevelopment\u002Ftesting.md\n- Python Samples: github.com\u002Ftemporalio\u002Fsamples-python\n\n## Limitations\n- Use this skill only when the task clearly matches the scope described above.\n- Do not treat the output as a substitute for environment-specific validation, testing, or expert review.\n- Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.\n","","imported","https:\u002F\u002Fgithub.com\u002Fsickn33\u002Fantigravity-awesome-skills","user_system_seed","SkillOPIC",true,246,1366,"2026-05-16 13:43:34",{"id":8,"name":21,"slug":22,"icon":23,"description":24,"sort":25,"createdAt":26},"编程开发","coding","mdi-code-braces","代码生成、调试、审查，提升开发效率",2,"2026-05-16 12:53:40",{"id":7,"name":28,"slug":29,"icon":30,"description":31,"moduleId":8,"sort":32,"skillCount":33,"createdAt":26},"代码审查","review","mdi-magnify-scan","代码质量分析、安全审查",4,145,[35],{"id":36,"skillId":4,"version":37,"fileName":38,"fileSize":39,"filePath":40,"fileHash":41,"manifest":42,"createdAt":19},"3037f8a1-f3d6-4d33-aa3a-1c835b7c3d7f","1.0.0","temporal-python-testing.zip",15834,"uploads\u002Fskills\u002F4cd22092-8065-4709-98b0-b700dc919446\u002Ftemporal-python-testing.zip","ac4ccd6b7b60ddc7f812f972c23e948ea9729645cabb42d8a3896870686d79b7","[{\"path\":\"SKILL.md\",\"isDirectory\":false,\"size\":5624},{\"path\":\"resources\u002Fintegration-testing.md\",\"isDirectory\":false,\"size\":12991},{\"path\":\"resources\u002Flocal-setup.md\",\"isDirectory\":false,\"size\":12069},{\"path\":\"resources\u002Freplay-testing.md\",\"isDirectory\":false,\"size\":12381},{\"path\":\"resources\u002Funit-testing.md\",\"isDirectory\":false,\"size\":8710}]",{"code":44,"message":45,"data":46},200,"success",{"items":47,"stats":48,"page":51},[],{"averageRating":49,"totalRatings":49,"ratingCounts":50},0,[49,49,49,49,49],{"limit":52,"offset":49,"hasMore":53,"nextOffset":52,"ratedOnly":16},15,false]