360 Secure SkillHub
360 安全技能中心

Skylv Test Case Generator

核心功能:分析源码结构,自动生成含正常路径、边界值、错误场景的单元/集成测试用例,适配Jest、Pytest、Mocha框架。典型场景:当你需要写测试、提升测试覆盖率、测试特定函数时使用。输入为源码文件,输出符合对应框架规范的测试文件,路径遵循项目约定。

sky-lv
sky-lv
热度 39.94
最近更新 2026-05-11 17:47:22
分类:开发依赖:读写文件 / 内部调用大模型应用场景:代码生成 / DevOps

安装技能

复制下面的话术发给你的 Agent,它会通过 secure-skills 检索并安装该技能。

执行命令安装此 skill: npx secure-skills-cli add skylv-test-case-generator
Metadata
name
skylv-test-writer
slug
skylv-test-writer
version
1.0.0
description
Auto-generates unit tests and integration tests from source code. Supports Jest, Pytest, Mocha. Triggers: write tests, generate tests, unit test, test coverage, testing scaffold.
author
SKY-lv
license
MIT
tags
["testing","jest","pytest","unit-test"]
keywords
["testing","unit-test","integration-test","jest","pytest","mocha"]
triggers
write tests, generate tests, test coverage

Test Writer

Overview

Analyzes source code and auto-generates comprehensive unit and integration tests.

When to Use

  • User asks to "write tests" or "add test coverage"
  • User wants to "test this function"

How It Works

Step 1: Detect test framework

Check: package.json (jest/mocha), pytest.ini, pyproject.toml, conftest.py

Step 2: Parse source

Read source files. Identify: function signatures, parameters, return types, error handling, edge cases.

Step 3: Generate test cases

For each function generate: happy path, edge cases (empty/null/zero), error cases, boundary cases.

Step 4: Write test file

JavaScript: tests/filename.test.js or filename.test.js Python: tests/test_filename.py

Templates

Jest

describe('functionName', () => { test('should return expected result', () => { expect(functionName(input)).toBe(expected); }); test('should throw for invalid input', () => { expect(() => functionName(invalid)).toThrow(); }); });

Pytest

def test_function_normal(): assert function_name(input) == expected

def test_function_invalid(): with pytest.raises(ErrorType): function_name(invalid)

Tips

  • Target 80%+ coverage on critical functions
  • Cover all branches and error paths
  • Mock external dependencies (API, filesystem, DB)