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
/\
/E2E\ <- Few, slow, expensive
/------\
/Integ- \ <- Some, moderate
/ ration \
/------------\
/ Unit Tests \ <- Many, fast, cheap
/________________\
Coverage Targets
| Type | Target | Focus |
|---|---|---|
| Unit | 80%+ | Functions, methods |
| Integration | 60%+ | Components, APIs |
| E2E | Critical paths | User workflows |
Framework Detection
JavaScript/TypeScript
Grep: "jest|vitest|mocha|jasmine" package.json
- Jest:
describe,it,expect - Vitest: Similar to Jest
- Mocha:
describe,it+ assertion library
Python
Grep: "pytest|unittest" requirements.txt
- pytest:
def test_*,assert - unittest:
class Test*,self.assert*
C#
Glob: **/*.csproj
Grep: "xunit|nunit|mstest"
- xUnit:
[Fact],[Theory] - NUnit:
[Test],[TestCase] - MSTest:
[TestMethod]
Test Generation Workflow
Step 1: Identify Target
# 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)
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)
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)
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
# JavaScript
npm test -- --coverage
# Python
pytest --cov=src --cov-report=html
# C#
dotnet test --collect:"XPlat Code Coverage"
Improvement Strategy
- Find uncovered lines
- Identify missing scenarios
- Add targeted tests
- Re-run coverage
Converted and distributed by TomeVault — claim your Tome and manage your conversions.