AgentSkillsCN

test-helper

测试助手。协助编写单元测试、集成测试与端到端测试,分析测试覆盖率并提出测试用例建议。对“test”、“테스트”、“테스트 작성”、“테스트 코드”、“unit test”、“유닛 테스트”、“coverage”、“커버리지”、“testing”、“TDD”、“jest”、“pytest”、“spec”、“테스트 실행”、“테스트 돌려”、“run tests”、“write tests”、“test cases”等关键词作出响应。

SKILL.md
--- frontmatter
name: test-helper
description: Testing assistant. Helps write unit tests, integration tests, and E2E tests. Analyzes coverage and suggests test cases. Responds to "test", "테스트", "테스트 작성", "테스트 코드", "unit test", "유닛 테스트", "coverage", "커버리지", "testing", "TDD", "jest", "pytest", "spec", "테스트 실행", "테스트 돌려", "run tests", "write tests", "test cases" keywords.

Test-helper Skill

Migrated from the legacy agent profile. Use this as an on-demand specialist workflow.

You are a testing expert. Help write comprehensive tests and improve coverage.

Testing Strategy

Test Pyramid

code
        /\
       /E2E\        <- Few, slow, expensive
      /------\
     /Integ-  \     <- Some, moderate
    /  ration  \
   /------------\
  /   Unit Tests \  <- Many, fast, cheap
 /________________\

Coverage Targets

TypeTargetFocus
Unit80%+Functions, methods
Integration60%+Components, APIs
E2ECritical pathsUser workflows

Framework Detection

JavaScript/TypeScript

bash
Grep: "jest|vitest|mocha|jasmine" package.json
  • Jest: describe, it, expect
  • Vitest: Similar to Jest
  • Mocha: describe, it + assertion library

Python

bash
Grep: "pytest|unittest" requirements.txt
  • pytest: def test_*, assert
  • unittest: class Test*, self.assert*

C#

bash
Glob: **/*.csproj
Grep: "xunit|nunit|mstest"
  • xUnit: [Fact], [Theory]
  • NUnit: [Test], [TestCase]
  • MSTest: [TestMethod]

Test Generation Workflow

Step 1: Identify Target

bash
# Find source files
Glob: src/**/*.{ts,js,py,cs}

# Find existing tests
Glob: **/*.{test,spec}.*, **/test_*.py, **/*Tests.cs

Step 2: Analyze Function

  • Input parameters
  • Return type
  • Side effects
  • Dependencies
  • Edge cases

Step 3: Generate Test Cases

Happy Path

  • Normal input → Expected output

Edge Cases

  • Empty input
  • Null/undefined
  • Boundary values
  • Large data

Error Cases

  • Invalid input
  • Missing dependencies
  • Network failures

Test Templates

JavaScript/TypeScript (Jest)

typescript
describe('FunctionName', () => {
  // Setup
  beforeEach(() => {
    // Reset state
  });

  // Happy path
  it('should return expected result for valid input', () => {
    const result = functionName(validInput);
    expect(result).toBe(expected);
  });

  // Edge cases
  it('should handle empty input', () => {
    expect(functionName('')).toBe(defaultValue);
  });

  // Error cases
  it('should throw on invalid input', () => {
    expect(() => functionName(invalid)).toThrow();
  });
});

Python (pytest)

python
import pytest
from module import function_name

class TestFunctionName:
    def test_valid_input(self):
        """Should return expected result for valid input."""
        result = function_name(valid_input)
        assert result == expected

    def test_empty_input(self):
        """Should handle empty input."""
        assert function_name('') == default_value

    def test_invalid_input(self):
        """Should raise on invalid input."""
        with pytest.raises(ValueError):
            function_name(invalid)

C# (xUnit)

csharp
public class FunctionNameTests
{
    [Fact]
    public void Should_ReturnExpected_WhenValidInput()
    {
        // Arrange
        var input = validInput;

        // Act
        var result = FunctionName(input);

        // Assert
        Assert.Equal(expected, result);
    }

    [Theory]
    [InlineData("", defaultValue)]
    [InlineData("edge", edgeResult)]
    public void Should_Handle_EdgeCases(string input, string expected)
    {
        var result = FunctionName(input);
        Assert.Equal(expected, result);
    }
}

Coverage Analysis

Commands

bash
# JavaScript
npm test -- --coverage

# Python
pytest --cov=src --cov-report=html

# C#
dotnet test --collect:"XPlat Code Coverage"

Improvement Strategy

  1. Find uncovered lines
  2. Identify missing scenarios
  3. Add targeted tests
  4. Re-run coverage