testing-strategies-sh-pxpeej
Installation
Review the source and dependencies with a prompt. A package is available to download.
Install with an AI assistant
Copy the prompt so your assistant can review the pinned revision and dependencies first.
View promptHide prompt
Check whether SkillPI Skill Finder is installed for your current agent. If it is missing, install and enable it using the official instructions at https://github.com/Findskills/skillpi. Then use Skill Finder to locate and install "testing-strategies-sh-pxpeej" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-ac55f0d81610664031a18d2ae1366a2bf59efc424fa6f6c4bf7b9da2ee0361e8. Verify the upstream source and version against https://skillhub.cn/skills/user_3c6cb52e/testing-strategies-sh-pxpeej before installing. If they do not match, stop and report the mismatch. Report the installed path and source version.
Source and setup
skillhub.cn
Setup guidance pending
See the original source for supported tools, dependencies, and permissions.
Installation test pending
Dedicated testing Strategies skill to help an AI Agent efficiently complete tasks related to testing strategies.
Introduction source: third_party · user_3c6cb52e · 1.0.0 Reference
SkillPi interpretation
- Tasks
- const result = await service.createOrder(input);
- Testing
- Not tested
Browse files
Frontmatter
name: 测试Strategies
slug: testing-strategies
version: 1.0.0
displayName: 测试Strategies
description: >
测试Strategies专用技能,帮助AI Agent高效完成相关任务。
summary: "测试Strategies专用技能,帮助AI Agent高效完成相关任务。"
license: MIT
category: 开发者工具
framework:
- Claude Code
- Codex
- Hermes Agent
- OpenClaw
- QClaw
- WorkBuddy
platform: multi-platform
homepage: "https://github.com/1991513ccie-png"
repository: "https://github.com/1991513ccie-png"Testing Strategies
Test Structure (Arrange-Act-Assert)
describe("OrderService", () => {
describe("createOrder", () => {
it("creates an order with valid items and returns order ID", async () => {
const repo = new InMemoryOrderRepository();
const service = new OrderService(repo);
const input = { customerId: "c1", items: [{ productId: "p1", quantity: 2 }] };
const result = await service.createOrder(input);
expect(result.id).toBeDefined();
expect(result.status).toBe("pending");
expect(result.items).toHaveLength(1);
const saved = await repo.findById(result.id);
expect(saved).toEqual(result);
});
it("rejects order with empty items", async () => {
const service = new OrderService(new InMemoryOrderRepository());
await expect(
service.createOrder({ customerId: "c1", items: [] })
).rejects.toThrow("Order must have at least one item");
});
});
});
Name tests by behavior, not method name. Each test should be independent and self-contained.
Contract Testing (Pact)
import { PactV4 } from "@pact-foundation/pact";
const provider = new PactV4({
consumer: "OrderService",
provider: "UserService",
});
describe("UserService contract", () => {
it("returns user by ID", async () => {
await provider
.addInteraction()
.given("user with id user-1 exists")
.uponReceiving("a request for user user-1")
.withRequest("GET", "/api/users/user-1")
.willRespondWith(200, (builder) => {
builder.jsonBody({
id: "user-1",
name: "Alice",
email: "alice@example.com",
});
})
.executeTest(async (mockServer) => {
const client = new UserClient(mockServer.url);
const user = await client.getUser("user-1");
expect(user.name).toBe("Alice");
});
});
});
Contract tests verify that consumer expectations match provider capabilities without requiring both services to be running.
Snapshot Testing
import { render } from "@testing-library/react";
it("renders the user profile card", () => {
const { container } = render(
<UserCard user={{ name: "Alice", email: "alice@example.com", role: "admin" }} />
);
expect(container).toMatchSnapshot();
});
it("renders the order summary with inline snapshot", () => {
const summary = formatOrderSummary(mockOrder);
expect(summary).toMatchInlineSnapshot(`
"Order #123
Items: 3
Total: $45.99
Status: Pending"
`);
});
Use inline snapshots for small outputs. Review snapshot diffs carefully during code review.
Property-Based Testing
import fc from "fast-check";
describe("sortUsers", () => {
it("always returns the same number of elements", () => {
fc.assert(
fc.property(
fc.array(fc.record({ name: fc.string(), age: fc.nat(120) })),
(users) => {
const sorted = sortUsers(users, "name");
return sorted.length === users.length;
}
)
);
});
it("produces a sorted result for any input", () => {
fc.assert(
fc.property(
fc.array(fc.record({ name: fc.string(), age: fc.nat(120) })),
(users) => {
const sorted = sortUsers(users, "age");
for (let i = 1; i < sorted.length; i++) {
if (sorted[i].age < sorted[i - 1].age) return false;
}
return true;
}
)
);
});
});
Integration Test with Test Containers
import { PostgreSqlContainer } from "@testcontainers/postgresql";
let container: any;
let db: Database;
beforeAll(async () => {
container = await new PostgreSqlContainer("postgres:16").start();
db = await createDatabase(container.getConnectionUri());
await db.migrate();
}, 60000);
afterAll(async () => {
await db.close();
await container.stop();
});
it("creates and retrieves a user", async () => {
const user = await db.user.create({ name: "Alice", email: "alice@test.com" });
const found = await db.user.findById(user.id);
expect(found).toEqual(user);
});
Test Doubles
function createMockEmailService(): EmailService {
const sent: Array<{ to: string; subject: string }> = [];
return {
send: async (to, subject, body) => { sent.push({ to, subject }); },
getSent: () => sent,
};
}
const emailService = createMockEmailService();
const service = new NotificationService(emailService);
await service.notifyUser("user-1", "Welcome");
expect(emailService.getSent()).toHaveLength(1);
expect(emailService.getSent()[0].subject).toBe("Welcome");
Anti-Patterns
- Testing implementation details instead of behavior
- Sharing mutable state between tests (no
beforeEachreset) - Writing tests that depend on execution order
- Mocking everything instead of using real dependencies for integration tests
- Ignoring flaky tests instead of fixing the root cause
- Testing trivial getters/setters while missing edge cases
Checklist
- [ ] Tests organized by behavior, not by method or file
- [ ] Each test follows Arrange-Act-Assert structure
- [ ] Contract tests verify inter-service API compatibility
- [ ] Snapshot tests reviewed during code review (not blindly updated)
- [ ] Property-based tests cover invariants for algorithmic code
- [ ] Integration tests use test containers for real dependencies
- [ ] Test doubles are minimal and behavior-focused
- [ ] CI fails on flaky test detection
Current listing version
1.0.0
Safety and assessment details
Quality assessment
Out of 100 · Assessment report from SkillPi LAB.
Highlights
- 提供完整的测试策略方法论,涵盖 Arrange-Act-Assert、Contract Testing、Snapshot Testing 等多种实用技术
- 包含丰富的代码示例和最佳实践清单,对开发者具有明确实用价值
Areas to improve
-
缺少显式触发关键词定义 Reported severity: Minor
description 描述了用途,但未提供具体的触发关键词(如“测试策略”、“单元测试”等),可能影响触发准确性
Recommendation: 在 description 或单独章节中明确定义触发关键词,如:当用户询问“如何写单元测试”、“测试策略有哪些”等时使用此技能
Highlights
- description 明确说明用途为测试策略相关任务,边界基本清晰
Areas to improve
-
缺少 When to Use 显式章节 Reported severity: Minor
内容组织良好,但未设置显式的 When to Use 章节来说明适用场景
Recommendation: 添加 When to Use 章节,明确说明在哪些场景下使用此技能(如编写测试代码、review 测试用例、学习测试方法等)
Highlights
- 结构清晰,分章节介绍不同测试策略,每部分配有完整代码示例
- 包含实用的 Checklist 作为执行出口条件
Highlights
- 作为知识型技能,内容准确可靠,代码示例语法正确
- 不涉及系统操作,无执行风险
The arithmetic mean of the first four original scores, rounded to a whole number.
Static text checks
100 / 100 · skillpi-20261123-no-r3-v1
No current rules matched the text.
This score reflects rule matches in the text and is provided for reference before use. It excludes attachments and runtime behavior.
Permissions and checks before use
Automatically summarized from this main document. Matches may be examples or defensive advice; they are not actual permission declarations. Attachments, external dependencies and runtime behavior are not covered.
These common operations were not identified in the main document. This does not mean no permissions or risks exist.
Domains or addresses referenced in the document
These addresses may be documentation links or examples, not an approved network allowlist. Verify actual destinations and outgoing data before use.
- github.com
Security rating and access scope
safe · Static evidence review; not a runtime safety guarantee.
Before use, confirm and authorize actual file access, external services and network destinations in your host. This review grants no runtime permissions.
User discussion
No verified reviews yet.