بنقرة واحدة
speckit-spectest-generate
Generate test scaffolds from spec acceptance criteria and user scenarios
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
القائمة
Generate test scaffolds from spec acceptance criteria and user scenarios
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
استنادا إلى تصنيف SOC المهني
| name | speckit-spectest-generate |
| description | Generate test scaffolds from spec acceptance criteria and user scenarios |
| compatibility | Requires spec-kit project structure with .specify/ directory |
| metadata | {"author":"github-spec-kit","source":"spectest:commands/speckit.spectest.generate.md"} |
Read spec artifacts (spec.md, plan.md, tasks.md) and generate ready-to-fill test scaffolds that cover every acceptance criterion, user scenario, and success criterion. Tests are organized by requirement and include descriptive names, setup hints, and assertion placeholders.
$ARGUMENTS
You MUST consider the user input before proceeding (if not empty). The user may specify:
.specify/scripts/bash/check-prerequisites.sh --json from the repo root and parsing FEATURE_DIR and AVAILABLE_DOCS. The spec lives at $FEATURE_DIR/spec.md (under specs/<feature>/), not under .specify/. If missing, stop with error: "Cannot generate tests without spec.md — run /speckit.specify first."spec.md completely to extract acceptance criteria, user scenarios, requirements, and success criteria.plan.md exists, read it to understand architecture, file structure, and technical decisions.tasks.md exists, read it to understand implementation phases and completed work.package.json, pyproject.toml, go.mod, pom.xml, Cargo.toml, or existing test files.Extract Testable Requirements: Parse spec artifacts to build a complete list of things to test.
spec.md → ## Requirements: Each requirement becomes a test suitespec.md → ## User Scenarios & Testing: Each scenario becomes a describe/context blockspec.md → ## Success Criteria: Each criterion becomes one or more test casesplan.md → Technical decisions: Each decision becomes a verification testDetect Test Environment: Identify the project's testing setup.
Generate Test File Structure: Create test files organized by requirement.
tests/
├── unit/
│ ├── auth/
│ │ ├── signup.test.ts ← REQ-001: User signup
│ │ ├── login.test.ts ← REQ-002: User login
│ │ └── token.test.ts ← REQ-003: JWT generation
│ └── middleware/
│ └── rateLimit.test.ts ← REQ-004: Rate limiting
├── integration/
│ └── auth-flow.test.ts ← Scenario: Full auth flow
└── e2e/
└── user-registration.test.ts ← Scenario: New user registration
Generate Test Scaffolds: For each requirement, produce a test file with:
Example (TypeScript/Jest):
/**
* Tests for REQ-001: User signup with email/password
* Source: spec.md → Requirements → "Users can sign up with email and password"
* Implementation: src/auth/signup.ts
*/
describe('User Signup', () => {
// Acceptance Criteria: Valid email and password creates account
describe('successful registration', () => {
it('should create a new user with valid email and password', () => {
// Arrange: prepare valid signup data
// Act: call signup function/endpoint
// Assert: user is created, returns success
throw new Error('TODO: implement test');
});
it('should hash the password before storing', () => {
// Arrange: prepare signup data
// Act: call signup, inspect stored password
// Assert: stored password is bcrypt hash, not plaintext
throw new Error('TODO: implement test');
});
});
// Acceptance Criteria: Duplicate email is rejected
describe('duplicate email handling', () => {
it('should reject signup with existing email', () => {
// Arrange: create user with email, attempt second signup
// Act: call signup with same email
// Assert: returns error, no duplicate created
throw new Error('TODO: implement test');
});
});
// Acceptance Criteria: Invalid email format is rejected
describe('email validation', () => {
it('should reject invalid email formats', () => {
// Arrange: prepare invalid emails
// Act: call signup with each
// Assert: validation error returned
throw new Error('TODO: implement test');
});
});
});
Example (Python/pytest):
"""
Tests for REQ-001: User signup with email/password
Source: spec.md → Requirements → "Users can sign up with email and password"
Implementation: src/auth/signup.py
"""
import pytest
class TestUserSignup:
"""Acceptance Criteria: Valid email and password creates account"""
def test_creates_user_with_valid_credentials(self):
# Arrange: prepare valid signup data
# Act: call signup function
# Assert: user is created
raise NotImplementedError("TODO: implement test")
def test_hashes_password_before_storing(self):
# Arrange: prepare signup data
# Act: call signup, inspect stored password
# Assert: password is hashed
raise NotImplementedError("TODO: implement test")
def test_rejects_duplicate_email(self):
# Arrange: create existing user
# Act: signup with same email
# Assert: raises appropriate error
raise NotImplementedError("TODO: implement test")
Generate Traceability Header: Each test file includes a header comment linking back to the spec.
Requirement: REQ-001
Spec Section: ## Requirements → "Users can sign up with email/password"
Implementation: src/auth/signup.ts
Plan Reference: plan.md → "Use bcrypt with cost factor 12"
Output Summary: Report what was generated.
## Generated Test Scaffolds
| Requirement | Test File | Test Cases | Type |
|-------------|-----------|------------|------|
| REQ-001: User signup | tests/unit/auth/signup.test.ts | 4 | Unit |
| REQ-002: User login | tests/unit/auth/login.test.ts | 3 | Unit |
| REQ-003: JWT tokens | tests/unit/auth/token.test.ts | 5 | Unit |
| Scenario: Auth flow | tests/integration/auth-flow.test.ts | 3 | Integration |
| Scenario: Registration | tests/e2e/user-registration.test.ts | 2 | E2E |
**Total: 17 test cases across 5 files**
Generate a human-readable diff between two spec versions showing exactly what changed
Generate a full changelog from spec git history showing all requirement changes over time
Generate stakeholder notifications summarizing spec changes for team communication
Generate release notes for a specific version or tag from spec changes
Generate a custom checklist for the current feature based on user requirements.
Identify underspecified areas in the current feature spec by asking up