Skip to content
Development
Command

/f5-test-unit

Unit testing operations

From plugin
f5-framework
2469 skills104 agents69 commands
Install
$ npx -y skills add Fujigo-Software/f5-framework-claude --agent claude-code

How it fires

How this command gets triggered: by you, by Claude, or both.

  • Fires itselfClaude auto-loads it when your prompt matches the work.
  • You can call itInvoke it directly when you want it.
  • Slash command/f5-test-unit

Context preview

What this command does when you run it.

Unit testing operations

Command definition

f5-test-unit.md
name: f5-test-unit
description: Unit testing operations
argument-hint: <generate|run> [path] [--coverage] [--fix]
allowed-tools: Read, Write, Glob, Grep, Bash
user-invocable: true

/f5-test-unit - Unit Testing

> **Version**: 1.4.0 > **Category**: Testing > **Purpose**: Unit testing trực tiếp với khả năng fix bug ngay

ARGUMENTS

The user's request is: $ARGUMENTS

---

COMMAND SYNTAX

# Test một file cụ thể
/f5-test-unit src/core/excel-processor.ts

# Test một thư mục
/f5-test-unit src/core/

# Test với auto-fix
/f5-test-unit src/core/excel-processor.ts --fix

# Test và generate report
/f5-test-unit src/core/ --report

# Test specific function
/f5-test-unit src/core/excel-processor.ts::parseFile

# Test changed files only
/f5-test-unit

---

FLAGS

| Flag | Description | |------|-------------| | `--fix` | Auto-fix bugs found | | `--report` | Generate test report | | `--verbose` | Detailed output | | `--coverage` | Calculate coverage estimate | | `--v1..--v5` | Verbosity levels |

---

INPUT PATTERNS

| Input | Type | Action | |-------|------|--------| | `*.ts` file | Single file | Test all exports | | `*/` directory | Directory | Test all files | | `file::function` | Specific | Test one function | | No input | Auto | Test changed files |

---

WORKFLOW

┌─────────────────────────────────────────────────────────────┐
│                   UNIT TEST WORKFLOW                         │
├─────────────────────────────────────────────────────────────┤
│                                                              │
│   /f5-test-unit [target]                                     │
│           │                                                  │
│           ▼                                                  │
│   ┌───────────────┐                                         │
│   │ Analyze Code  │                                         │
│   │ • Parse exports                                         │
│   │ • Identify deps                                         │
│   │ • Detect testable units                                 │
│   └───────┬───────┘                                         │
│           │                                                  │
│           ▼                                                  │
│   ┌───────────────┐     ┌───────────────┐                   │
│   │ Execute Tests │────▶│ Bug Found?    │                   │
│   └───────────────┘     └───────┬───────┘                   │
│                                 │                            │
│                    Yes ─────────┼───────── No                │
│                    ▼            │            ▼               │
│           ┌───────────────┐     │    ┌───────────────┐      │
│           │ --fix flag?   │     │    │ ✅ All Pass   │      │
│           └───────┬───────┘     │    └───────────────┘      │
│                   │             │                            │
│          Yes ─────┼───── No     │                           │
│          ▼        │       ▼     │                           │
│   ┌─────────────┐ │ ┌─────────────┐                         │
│   │ Auto-Fix    │ │ │ Suggest Fix │                         │
│   │ & Re-test   │ │ │ (Manual)    │                         │
│   └─────────────┘ │ └─────────────┘                         │
│                                                              │
└─────────────────────────────────────────────────────────────┘

---

TEST CATEGORIES

| Category | Description | Priority | |----------|-------------|----------| | **Happy Path** | Normal input → Expected output | High | | **Edge Cases** | Boundary values, empty input | High | | **Error Cases** | Invalid input → Proper error | Medium | | **Type Safety** | Type validation | Medium |

---

SOURCE ANALYSIS OUTPUT

## 📊 Source Analysis: [filename]

### Exports Found
| Name | Type | Lines | Complexity |
|------|------|-------|------------|
| parseFile | function | 45-120 | Medium |
| validateData | function | 122-150 | Low |

### Dependencies
- fs-extra (external)
- xlsx (external)
- ./types (internal)

### Test Cases Identified
| Function | Happy | Edge | Error | Total |
|----------|-------|------|-------|-------|
| parseFile | 3 | 2 | 2 | 7 |
| validateData | 2 | 1 | 1 | 4 |

---

BUG DETECTION & AUTO-FIX

When Bug Found

## 🐛 Bug Detected

**File:** src/core/excel-processor.ts
**Function:** parseFile
**Line:** 78

### Issue
```typescript
// Current code (buggy):
if (data.length = 0) {  // ❌ Assignment instead of comparison
  return null;
}

Root Cause

Using `=` instead of `===` in condition check.

Suggested Fix

// Fixed code:
if (data.length === 0) {  // ✅ Correct comparison
  return null;
}

### With --fix Flag

```markdown
## 🔧 Auto-Fix Applied

**File:** src/core/excel-processor.ts

### Changes Made
| Line | Before | After |
|------|--------|-------|
| 78 | `if (data.length = 0)` | `if (data.length === 0)` |

### Verification
- Re-running test case...
- Result: ✅ PASS

---

OUTPUT FORMATS

Minimal (--v1)

Unit Test: src/core/excel-processor.ts
Result: 9/11 ✅ | 2 ❌ (auto-fixed 1)

Concise (--v2)

## Unit Test: excel-processor.ts

✅ 9 passed | ❌ 2 failed

**Failed:**
- parseFile: Empty file handling → Auto-fixed ✅
- validateData: Error message → Manual fix needed

**Next:** Fix validateData or `/f5-test-unit --fix`

Balanced (--v3, default)

Full report với summary, failed tests, và suggestions.

Detailed (--v4) / Comprehensive (--v5)

Includes all test cases, code paths, và detailed analysis.

---

TEST REPORT

## 🧪 Unit Test Report

**Target:** src/core/excel-processor.ts
**Date:** [timestamp]
**Duration:** [time]

### Summary
| Metric | Value |
|--------|-------|
| Total Tests | 11 |
| Passed | 9 |
| Failed | 2 |
| Pass Rate | 81.8% |

### Results by Function
| Function | Tests | Pass | Fail | Status |
|----------|-------|------|------|
Read more
Ships withf5-framework

AI-Powered Development Framework for Claude Code

Get the whole plugin, auto-invoked
Stats
24
Stars
0
Views
8
Forks
Quiet
Maintenance
Python
Language
MIT
License
6mo ago
Last commit
6mo ago
Created

Repo: Fujigo-Software/f5-framework-claude