Get the FREE Ultimate OpenClaw Setup Guide →

test-writer

Scanned
npx machina-cli add skill athola/skrills/test-writer --openclaw
Files (1)
SKILL.md
872 B

Test Writer

Expert at writing tests that ensure code quality and prevent regressions.

Test Types

  • Unit Tests: Test individual functions in isolation
  • Integration Tests: Test component interactions
  • E2E Tests: Test complete user workflows

Testing Principles

  • Arrange, Act, Assert (AAA) pattern
  • One assertion per test when practical
  • Test edge cases and error conditions
  • Use meaningful test descriptions

Coverage Guidelines

  • Aim for meaningful coverage, not just high percentages
  • Focus on critical paths and business logic
  • Test both happy paths and error scenarios
  • Include boundary value tests

Mocking Strategy

  • Mock external dependencies
  • Use dependency injection for testability
  • Avoid over-mocking internal implementation

Source

git clone https://github.com/athola/skrills/blob/master/assets/demo-skills/test-writer/SKILL.mdView on GitHub

Overview

Test Writer helps engineers craft comprehensive tests that guard code quality and prevent regressions. It covers unit, integration, and E2E testing, following AAA patterns and meaningful coverage guidelines to ensure critical paths are protected.

How This Skill Works

Tests follow Arrange, Act, Assert (AAA) with deliberate one-assertion-per-test guidance. The skill promotes selecting the right test type (unit, integration, E2E), using dependency injection to mock external dependencies, and validating both happy paths and error conditions.

When to Use It

  • When adding new features, to validate logic with unit tests.
  • When verifying interactions between components, via integration tests.
  • When validating complete user workflows, using E2E tests in CI.
  • When adding regression tests to guard against past bugs.
  • When documenting expectations with meaningful test descriptions.

Quick Start

  1. Step 1: Identify test type and outline the scenarios to cover (unit, integration, E2E).
  2. Step 2: Write tests using Arrange, Act, Assert; create mocks for external dependencies via dependency injection.
  3. Step 3: Run tests locally and in CI, review results, and iterate on failures.

Best Practices

  • Apply AAA in every test, with clear Arrange/Act/Assert blocks.
  • Prefer one assertion per test when practical to keep tests focused.
  • Write tests for edge cases, error conditions, and boundary values.
  • Use descriptive names that convey intent and expected outcome.
  • Use dependency injection to mock external dependencies; avoid over-mocking internal logic.

Example Use Cases

  • Unit test for a function that calculates a discount with boundary values.
  • Integration test ensuring a service interacts with a database through a repository interface.
  • E2E test simulating user registration and onboarding.
  • Regression test to lock in a bug fix for a payment processing error.
  • Boundary test for input validation (e.g., max length, min values).

Frequently Asked Questions

Add this skill to your agents
Sponsor this space

Reach thousands of developers