supertester-otp-testing
This skill should be used when teams need to adopt Supertester to build deterministic Elixir OTP tests with isolation, synchronization, and supervision coverage.
$ インストール
git clone https://github.com/nshkrdotcom/supertester /tmp/supertester && cp -r /tmp/supertester/.claude/skills/supertester-skill ~/.claude/skills/supertester// tip: Run this command in your terminal to install the skill
SKILL.md
name: supertester-otp-testing description: This skill should be used when teams need to adopt Supertester to build deterministic Elixir OTP tests with isolation, synchronization, and supervision coverage. license: Complete terms in LICENSE
Supertester OTP Testing
When To Trigger
- Activate whenever writing or reviewing new OTP-heavy tests so Supertester foundations are considered before adding bespoke helpers.
- Activate when eliminating flaky OTP tests,
Process.sleep/1calls, or race conditions in Elixir suites. - Activate when installing or upgrading Supertester and clarifying how OTP helpers should shape new or existing tests.
- Activate when validating supervision restarts, chaos scenarios, or performance contracts with Supertester-provided tooling.
Core Goals
- Establish isolation with
Supertester.UnifiedTestFoundationand run OTP tests safely withasync: true. - Retrofit GenServers and supervisors to use deterministic synchronization via Supertester helpers.
- Replace bespoke OTP utilities with the official helpers and assertions in
lib/supertester. - Surface reusable diagnostics that make failures obvious and repeatable.
Quick Orientation
- Review
README.mdfor feature highlights and before/after examples. - Use
MANUAL.mdfor full API coverage; jump to the “OTP Testing Helpers” section for signatures. - Keep
docs/QUICK_START.mdon hand for migration recipes and example code. - Inspect source modules directly (
lib/supertester/otp_helpers.ex,lib/supertester/genserver_helpers.ex,lib/supertester/unified_test_foundation.ex,lib/supertester/testable_genserver.ex,lib/supertester/assertions.ex) whenever implementation details matter.
Setup Workflow
- Add
{:supertester, "~> 0.2.1", only: :test}tomix.exsand runmix deps.getto install. - Use
Supertester.UnifiedTestFoundationin each OTP-heavy test module, defaulting toisolation: :full_isolationunless constraints require lighter modes. - Import helper namespaces explicitly:
import Supertester.OTPHelpers import Supertester.GenServerHelpers import Supertester.Assertions - Mark eligible cases
async: true(automatically supplied by the isolation macro) and rely on helper-driven cleanup instead of manual teardown.
GenServer Workflow
- Start isolated servers via
setup_isolated_genserver/3, passing custom:init_argsor explicit names through opts. - Apply
use Supertester.TestableGenServerinside target modules to expose the__supertester_sync__handler without redefininghandle_call/3. - Replace bare casts with
cast_and_sync/3followed byassert_genserver_state/2orassert_genserver_responsive/1. - Leverage
call_with_timeout/3,get_server_state_safely/1,monitor_process_lifecycle/1, andcleanup_on_exit/1to observe asynchronous behavior deterministically.
Example Pattern
defmodule MyApp.CounterTest do
use ExUnit.Case
use Supertester.UnifiedTestFoundation, isolation: :full_isolation
import Supertester.OTPHelpers
import Supertester.GenServerHelpers
import Supertester.Assertions
test "increments without race conditions" do
{:ok, counter} = setup_isolated_genserver(MyApp.Counter)
:ok = cast_and_sync(counter, :increment)
assert_genserver_state(counter, fn state -> state.count == 1 end)
end
end
Supervisor & Restart Testing
- Start trees with
setup_isolated_supervisor/3and confirm readiness throughwait_for_supervisor_restart/2orwait_for_supervisor_stabilization/2. - Probe restart semantics using
test_restart_strategy/3, then assert outcomes with helpers such asassert_process_restarted/2andassert_all_children_alive/1. - Trace living supervision events via
trace_supervision_events/2to capture restarts without manual logging. - Enable
isolation: :contamination_detectionwhen diagnosing leaks; review warnings emitted bySupertester.UnifiedTestFoundation.
Chaos And Performance Hooks
- Exercise resilience with
Supertester.ChaosHelpers, following scenario setups inREADME.mdand option references inMANUAL.md. - Guard service-level objectives using
Supertester.PerformanceHelpers, pairingassert_performance/2orassert_no_memory_leak/2with isolated fixtures.
Assertions & Diagnostics
- Favor OTP-aware checks from
lib/supertester/assertions.ex(assert_genserver_handles_message/3,assert_process_dead/1,assert_no_process_leaks/1) instead of bespoke assertions. - Run
verify_test_isolation/1when isolations feel suspect to confirm all tracked processes remain sandboxed. - Capture process exits intentionally with
wait_for_process_death/2and translate restarts to deterministic expectations.
Reference Bundle
- Load
MANUAL.md#otp-testing-helpersfor signature verification mid-task. - Consult
docs/API_GUIDE.mdfor extended examples and edge-case notes. - Check
CHANGELOG.mdbefore depending on newer APIs or behavior changes.
Reuse Checklist
- Confirm each GenServer under test
use Supertester.TestableGenServer. - Ensure every asynchronous assertion flows through
cast_and_sync/3,wait_for_genserver_sync/2, or equivalent helpers. - Replace any remaining
Process.sleep/1usage with Supertester synchronization. - Remove redundant in-house OTP helpers once the Supertester equivalents are adopted.
Repository

nshkrdotcom
Author
nshkrdotcom/supertester/.claude/skills/supertester-skill
4
Stars
0
Forks
Updated1w ago
Added1w ago