[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M71C68Z93GTMSP7BC2S9VDXP":3,"skill-same:01M71C68Z93GTMSP7BC2S9VDXP":70},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":23,"publishedAt":37,"linkOnly":38,"markdownContent":39,"markdownBody":40,"frontMatter":41,"refName":43,"commitSha":44,"skillDirectory":45,"forksCount":14,"repositoryHtmlUrl":46,"repositoryHomepageUrl":6,"ownerHtmlUrl":47,"ownerBlogUrl":6,"ownerDescription":48,"updatedAt":49,"install":50,"resources":63},"01M71C68Z93GTMSP7BC2S9VDXP","testing-patterns",null,"Testing patterns and principles. Unit, integration, mocking strategies.","yqecea\u002Fgem-swarm","yqecea","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F196189405?v=4","01M71C12KWH5QPTE12J69335KF","Yusuf","01M71C12MFS3BRGNE5SSHB4DY9",1,"Apache-2.0","https:\u002F\u002Fgithub.com\u002Fyqecea\u002Fgem-swarm\u002Fblob\u002Fmain\u002Fsrc\u002Fskills\u002Fdomain\u002Ftesting-patterns\u002FSKILL.md",[18],{"categoryNo":19,"categoryName":20,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000008","测试与质量","SCENARIO","使用场景",[24,25,26,27,28,29,30,31,32,33,34,35,36],"testing patterns","testing","patterns","unit","mocking","Bash","strategies","principles","read","integration","write","edit","grep","2026-11-10 10:12:30",false,"---\nname: testing-patterns\ndescription: Testing patterns and principles. Unit, integration, mocking strategies.\nallowed-tools: Read, Write, Edit, Glob, Grep, Bash\n---\n\n# Testing Patterns\n\n> Principles for reliable test suites.\n\n---\n\n## 1. Testing Pyramid\n\n```\n        \u002F\\          E2E (Few)\n       \u002F  \\         Critical flows\n      \u002F----\\\n     \u002F      \\       Integration (Some)\n    \u002F--------\\      API, DB queries\n   \u002F          \\\n  \u002F------------\\    Unit (Many)\n                    Functions, classes\n```\n\n---\n\n## 2. AAA Pattern\n\n| Step | Purpose |\n|------|---------|\n| **Arrange** | Set up test data |\n| **Act** | Execute code under test |\n| **Assert** | Verify outcome |\n\n---\n\n## 3. Test Type Selection\n\n### When to Use Each\n\n| Type | Best For | Speed |\n|------|----------|-------|\n| **Unit** | Pure functions, logic | Fast (\u003C50ms) |\n| **Integration** | API, DB, services | Medium |\n| **E2E** | Critical user flows | Slow |\n\n---\n\n## 4. Unit Test Principles\n\n### Good Unit Tests\n\n| Principle | Meaning |\n|-----------|---------|\n| Fast | \u003C 100ms each |\n| Isolated | No external deps |\n| Repeatable | Same result always |\n| Self-checking | No manual verification |\n| Timely | Written with code |\n\n### What to Unit Test\n\n| Test | Don't Test |\n|------|------------|\n| Business logic | Framework code |\n| Edge cases | Third-party libs |\n| Error handling | Simple getters |\n\n---\n\n## 5. Integration Test Principles\n\n### What to Test\n\n| Area | Focus |\n|------|-------|\n| API endpoints | Request\u002Fresponse |\n| Database | Queries, transactions |\n| External services | Contracts |\n\n### Setup\u002FTeardown\n\n| Phase | Action |\n|-------|--------|\n| Before All | Connect resources |\n| Before Each | Reset state |\n| After Each | Clean up |\n| After All | Disconnect |\n\n---\n\n## 6. Mocking Principles\n\n### When to Mock\n\n| Mock | Don't Mock |\n|------|------------|\n| External APIs | The code under test |\n| Database (unit) | Simple dependencies |\n| Time\u002Frandom | Pure functions |\n| Network | In-memory stores |\n\n### Mock Types\n\n| Type | Use |\n|------|-----|\n| Stub | Return fixed values |\n| Spy | Track calls |\n| Mock | Set expectations |\n| Fake | Simplified implementation |\n\n---\n\n## 7. Test Organization\n\n### Naming\n\n| Pattern | Example |\n|---------|---------|\n| Should behavior | \"should return error when...\" |\n| When condition | \"when user not found...\" |\n| Given-when-then | \"given X, when Y, then Z\" |\n\n### Grouping\n\n| Level | Use |\n|-------|-----|\n| describe | Group related tests |\n| it\u002Ftest | Individual case |\n| beforeEach | Common setup |\n\n---\n\n## 8. Test Data\n\n### Strategies\n\n| Approach | Use |\n|----------|-----|\n| Factories | Generate test data |\n| Fixtures | Predefined datasets |\n| Builders | Fluent object creation |\n\n### Principles\n\n- Use realistic data\n- Randomize non-essential values (faker)\n- Share common fixtures\n- Keep data minimal\n\n---\n\n## 9. Best Practices\n\n| Practice | Why |\n|----------|-----|\n| One assert per test | Clear failure reason |\n| Independent tests | No order dependency |\n| Fast tests | Run frequently |\n| Descriptive names | Self-documenting |\n| Clean up | Avoid side effects |\n\n---\n\n## 10. Anti-Patterns\n\n| ❌ Don't | ✅ Do |\n|----------|-------|\n| Test implementation | Test behavior |\n| Duplicate test code | Use factories |\n| Complex test setup | Simplify or split |\n| Ignore flaky tests | Fix root cause |\n| Skip cleanup | Reset state |\n\n---\n\n> **Remember:** Tests are documentation. If someone can't understand what the code does from the tests, rewrite them.\n","# Testing Patterns\n\n> Principles for reliable test suites.\n\n---\n\n## 1. Testing Pyramid\n\n```\n        \u002F\\          E2E (Few)\n       \u002F  \\         Critical flows\n      \u002F----\\\n     \u002F      \\       Integration (Some)\n    \u002F--------\\      API, DB queries\n   \u002F          \\\n  \u002F------------\\    Unit (Many)\n                    Functions, classes\n```\n\n---\n\n## 2. AAA Pattern\n\n| Step | Purpose |\n|------|---------|\n| **Arrange** | Set up test data |\n| **Act** | Execute code under test |\n| **Assert** | Verify outcome |\n\n---\n\n## 3. Test Type Selection\n\n### When to Use Each\n\n| Type | Best For | Speed |\n|------|----------|-------|\n| **Unit** | Pure functions, logic | Fast (\u003C50ms) |\n| **Integration** | API, DB, services | Medium |\n| **E2E** | Critical user flows | Slow |\n\n---\n\n## 4. Unit Test Principles\n\n### Good Unit Tests\n\n| Principle | Meaning |\n|-----------|---------|\n| Fast | \u003C 100ms each |\n| Isolated | No external deps |\n| Repeatable | Same result always |\n| Self-checking | No manual verification |\n| Timely | Written with code |\n\n### What to Unit Test\n\n| Test | Don't Test |\n|------|------------|\n| Business logic | Framework code |\n| Edge cases | Third-party libs |\n| Error handling | Simple getters |\n\n---\n\n## 5. Integration Test Principles\n\n### What to Test\n\n| Area | Focus |\n|------|-------|\n| API endpoints | Request\u002Fresponse |\n| Database | Queries, transactions |\n| External services | Contracts |\n\n### Setup\u002FTeardown\n\n| Phase | Action |\n|-------|--------|\n| Before All | Connect resources |\n| Before Each | Reset state |\n| After Each | Clean up |\n| After All | Disconnect |\n\n---\n\n## 6. Mocking Principles\n\n### When to Mock\n\n| Mock | Don't Mock |\n|------|------------|\n| External APIs | The code under test |\n| Database (unit) | Simple dependencies |\n| Time\u002Frandom | Pure functions |\n| Network | In-memory stores |\n\n### Mock Types\n\n| Type | Use |\n|------|-----|\n| Stub | Return fixed values |\n| Spy | Track calls |\n| Mock | Set expectations |\n| Fake | Simplified implementation |\n\n---\n\n## 7. Test Organization\n\n### Naming\n\n| Pattern | Example |\n|---------|---------|\n| Should behavior | \"should return error when...\" |\n| When condition | \"when user not found...\" |\n| Given-when-then | \"given X, when Y, then Z\" |\n\n### Grouping\n\n| Level | Use |\n|-------|-----|\n| describe | Group related tests |\n| it\u002Ftest | Individual case |\n| beforeEach | Common setup |\n\n---\n\n## 8. Test Data\n\n### Strategies\n\n| Approach | Use |\n|----------|-----|\n| Factories | Generate test data |\n| Fixtures | Predefined datasets |\n| Builders | Fluent object creation |\n\n### Principles\n\n- Use realistic data\n- Randomize non-essential values (faker)\n- Share common fixtures\n- Keep data minimal\n\n---\n\n## 9. Best Practices\n\n| Practice | Why |\n|----------|-----|\n| One assert per test | Clear failure reason |\n| Independent tests | No order dependency |\n| Fast tests | Run frequently |\n| Descriptive names | Self-documenting |\n| Clean up | Avoid side effects |\n\n---\n\n## 10. Anti-Patterns\n\n| ❌ Don't | ✅ Do |\n|----------|-------|\n| Test implementation | Test behavior |\n| Duplicate test code | Use factories |\n| Complex test setup | Simplify or split |\n| Ignore flaky tests | Fix root cause |\n| Skip cleanup | Reset state |\n\n---\n\n> **Remember:** Tests are documentation. If someone can't understand what the code does from the tests, rewrite them.\n",{"name":5,"description":7,"allowed-tools":42},"Read, Write, Edit, Glob, Grep, Bash","main","923c514d4d5e15bbfd65ec7eaf949a997679aa3e","src\u002Fskills\u002Fdomain\u002Ftesting-patterns","https:\u002F\u002Fgithub.com\u002Fyqecea\u002Fgem-swarm","https:\u002F\u002Fgithub.com\u002Fyqecea","15 y.o Data Science,Student","2026-04-26 20:00:27",{"source":8,"skillName":5,"commands":51,"prompt":61,"zipAvailable":62},[52,55,58],{"tool":53,"command":54},"npx","npx skills add yqecea\u002Fgem-swarm --skill testing-patterns",{"tool":56,"command":57},"bunx","bunx skills add yqecea\u002Fgem-swarm --skill testing-patterns",{"tool":59,"command":60},"pnpm","pnpm dlx skills add yqecea\u002Fgem-swarm --skill testing-patterns","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fyqecea\u002Fgem-swarm\u002Fblob\u002Fmain\u002Fsrc\u002Fskills\u002Fdomain\u002Ftesting-patterns\u002FSKILL.md",true,[64],{"path":65,"resourceType":66,"resourceTypeDesc":67,"sizeBytes":68,"sourceHtmlUrl":69},"scripts\u002Ftest_runner.py","SCRIPT","脚本",7078,"https:\u002F\u002Fgithub.com\u002Fyqecea\u002Fgem-swarm\u002Fblob\u002Fmain\u002Fsrc\u002Fskills\u002Fdomain\u002Ftesting-patterns\u002Fscripts\u002Ftest_runner.py",[71,85,99,110,122,145],{"skillNo":72,"name":73,"nameZh":6,"description":74,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":75,"categories":76,"keywords":77,"publishedAt":37},"01M71C74XVPP23ST10E8MYJZA0","validation","Cross-cutting validation methodology for verifying phase outputs and project integrity","https:\u002F\u002Fgithub.com\u002Fyqecea\u002Fgem-swarm\u002Fblob\u002Fmain\u002Fsrc\u002Fskills\u002Fshared\u002Fvalidation\u002FSKILL.md",[],[73,78,79,80,81,82,83,84],"validation methodology","for","project","outputs","phase","methodology","integrity",{"skillNo":86,"name":87,"nameZh":6,"description":88,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":89,"categories":90,"keywords":91,"publishedAt":37},"01M71C72PTKRV481M975R3QDDE","session-management","Manages orchestration session state, tracking, and resumption","https:\u002F\u002Fgithub.com\u002Fyqecea\u002Fgem-swarm\u002Fblob\u002Fmain\u002Fsrc\u002Fskills\u002Fshared\u002Fsession-management\u002FSKILL.md",[],[92,93,94,95,96,97,98],"session management","session","management","session state","orchestration","state","tracking",{"skillNo":100,"name":101,"nameZh":6,"description":102,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":103,"categories":104,"keywords":105,"publishedAt":37},"01M71C6ZY1EGM4SGVYT4B2HHD7","implementation-planning","Generates detailed implementation plans from finalized designs","https:\u002F\u002Fgithub.com\u002Fyqecea\u002Fgem-swarm\u002Fblob\u002Fmain\u002Fsrc\u002Fskills\u002Fshared\u002Fimplementation-planning\u002FSKILL.md",[],[106,107,108,109],"planning","implementation","implementation planning","plans",{"skillNo":111,"name":112,"nameZh":6,"description":113,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":114,"categories":115,"keywords":116,"publishedAt":37},"01M71C6XQVGMDFJ50BP5SBDS76","execution","Phase execution methodology for orchestration workflows with error handling and completion protocols","https:\u002F\u002Fgithub.com\u002Fyqecea\u002Fgem-swarm\u002Fblob\u002Fmain\u002Fsrc\u002Fskills\u002Fshared\u002Fexecution\u002FSKILL.md",[],[112,79,83,117,118,96,82,119,120,121],"error","workflows","protocols","error handling","with",{"skillNo":123,"name":124,"nameZh":6,"description":125,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":126,"categories":127,"keywords":136,"publishedAt":37},"01M71C6VY8APWMNK1XEJ3WP7A2","design-dialogue","Guides structured design conversations for complex engineering tasks","https:\u002F\u002Fgithub.com\u002Fyqecea\u002Fgem-swarm\u002Fblob\u002Fmain\u002Fsrc\u002Fskills\u002Fshared\u002Fdesign-dialogue\u002FSKILL.md",[128,131],{"categoryNo":129,"categoryName":130,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000015","视觉设计",{"categoryNo":132,"categoryName":133,"taxonomyType":134,"taxonomyTypeDesc":135},"01JBSEEDCAT000000000000032","设计师","PROFESSION","适用职业",[137,138,139,140,141,79,142,143,144],"dialogue","design","design dialogue","guides","conversations","tasks","engineering","structured",{"skillNo":146,"name":147,"nameZh":6,"description":148,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":149,"categories":150,"keywords":157,"publishedAt":37},"01M71C6R4RJWG3S2R26778TPD8","delegation","Agent delegation best practices for constructing effective subagent prompts with proper scoping","https:\u002F\u002Fgithub.com\u002Fyqecea\u002Fgem-swarm\u002Fblob\u002Fmain\u002Fsrc\u002Fskills\u002Fshared\u002Fdelegation\u002FSKILL.md",[151,154],{"categoryNo":152,"categoryName":153,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000010","后端与接口",{"categoryNo":155,"categoryName":156,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000023","Skill与智能体开发",[147,158,159,79,160,121,161],"subagent","scoping","best practices","prompts"]