원클릭으로
gen-tests
Generate high-quality tests for OhMyCode modules. Use when user wants to create, add, or generate tests for a module or file.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
Generate high-quality tests for OhMyCode modules. Use when user wants to create, add, or generate tests for a module or file.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
Run OhMyCode benchmarks — score any provider/model with token tracking. Use when user wants to benchmark, evaluate, test performance, or compare models.
Run tests and analyze results for OhMyCode. Use when user wants to run, check, or verify tests — or after any code change.
Guide for debugging OhMyCode issues. Use when user reports errors, unexpected behavior, or connection problems.
Guide for adding a new feature to OhMyCode. Use when user wants to add functionality that goes beyond existing extension points (tools/providers). Always start by reading docs/DEVELOPMENT_GUIDE.md.
Guide for adding a new LLM provider to OhMyCode. Use when user wants to connect a new AI model backend.
Guide for adding a new tool to OhMyCode. Use when user wants to create a custom tool.
| name | gen-tests |
| description | Generate high-quality tests for OhMyCode modules. Use when user wants to create, add, or generate tests for a module or file. |
Generate project-convention-compliant tests for a given module or file.
This skill is part of the OhMyCode development closed-loop:
编码 ──→ /gen-tests ──→ /run-tests ──→ 分析失败 ──→ 修代码 ──╮
↑ │
╰────────────────────────────────────────────────────────────╯
After generating tests, always proceed to /run-tests to verify them.
ohmycode/tools/bash.py, core/loop)$ARGUMENTS — module name or file path to test (e.g., ohmycode/tools/bash.py, core/loop, providers/anthropic).
If $ARGUMENTS is empty, ask the user which module to generate tests for.
Map the argument to a source file path:
| Argument form | Resolved source path |
|---|---|
ohmycode/tools/bash.py | use as-is |
tools/bash | ohmycode/tools/bash.py |
core/loop | ohmycode/core/loop.py |
providers/openai | ohmycode/providers/openai.py |
config | ohmycode/config/config.py |
Read the resolved source file. Identify:
_private unless critical)Read tests/conftest.py to learn available fixtures:
MockProvider — fake LLM that yields configurable responses, use for anything touching providersmock_provider — fixture returning a default MockProvider()mock_config — minimal config dicttmp_dir — alias for tmp_path, use for file-based testsCheck for existing test file at the mirror path (see Step 4 path rule). If it exists, read it to understand current coverage and style — extend rather than overwrite.
List test scenarios before writing code. Cover three categories:
| Category | Examples |
|---|---|
| Happy path | Normal input → expected output |
| Error / failure | Invalid input, missing params, API errors → graceful error |
| Edge cases | Empty input, huge input, concurrent calls, boundary values |
For each scenario, write a one-line description:
- test_bash_echo: simple command returns stdout
- test_bash_exit_code: non-zero exit → is_error=True
- test_bash_timeout: long command + short timeout → timeout error
Source ohmycode/X/Y.py → Test tests/X/test_Y.py
Examples:
ohmycode/tools/bash.py → tests/tools/test_bash.pyohmycode/core/loop.py → tests/core/test_loop.pyohmycode/providers/openai.py → tests/providers/test_openai_provider.pyEnsure tests/X/__init__.py exists (create empty if needed).
@pytest.mark.asynciotmp_path or tmp_dir fixture for any file I/Otmp_pathimport pytest
from ohmycode.tools.base import ToolContext
from ohmycode.tools.<module> import <ToolClass>
@pytest.fixture
def ctx(tmp_path):
return ToolContext(mode="auto", agent_depth=0, cwd=str(tmp_path), is_sub_agent=False)
@pytest.mark.asyncio
async def test_<tool>_basic(ctx):
tool = <ToolClass>()
result = await tool.execute({"param": "value"}, ctx)
assert not result.is_error
assert "expected" in result.output
@pytest.mark.asyncio
async def test_<tool>_error(ctx):
tool = <ToolClass>()
result = await tool.execute({"bad_param": ""}, ctx)
assert result.is_error
import pytest
from ohmycode.config.config import OhMyCodeConfig
from ohmycode.core.<module> import <Class>
@pytest.mark.asyncio
async def test_<feature>_happy_path(mock_provider):
config = OhMyCodeConfig(provider="mock", model="test", mode="auto", api_key="x")
obj = <Class>(config=config)
obj._provider = mock_provider
# setup and assertions ...
@pytest.mark.asyncio
async def test_<feature>_error(mock_provider):
# test error handling path
...
import pytest
from ohmycode.providers.base import PROVIDER_REGISTRY
def test_<provider>_is_registered():
import ohmycode.providers.<module> # noqa: F401
assert "<provider_name>" in PROVIDER_REGISTRY
def test_<provider>_instantiation():
from ohmycode.providers.<module> import <ProviderClass>
provider = <ProviderClass>(api_key="test-key", base_url="http://localhost:8080/v1")
assert provider.name == "<provider_name>"
/run-testsAfter writing the test file, immediately use /run-tests to execute and verify:
/run-tests X/Y (e.g., /run-tests tools/bash)/run-tests will handle: execution, failure analysis, regression checkIf /run-tests reports failures:
/run-tests/run-testsBefore finishing, verify:
tmp_path used for file I/Oconftest.py reused where applicable@pytest.mark.asyncio__init__.py/run-tests confirms: new tests pass + full suite has no regressions→ /run-tests — always run tests after generating them