Testing strategies for OCaml libraries. Use when discussing tests, alcotest, eio mocks, test structure, or test-driven development in OCaml projects.
/plugin marketplace add avsm/ocaml-claude-marketplace/plugin install avsm-ocaml-dev-plugins-ocaml-dev@avsm/ocaml-claude-marketplaceThis skill inherits all available tools. When active, it can use any tool Claude has access to.
templates/test_eio_mock.mltemplates/test_template.mlInvoke this skill when:
Tests use Alcotest. See templates/test_template.ml for the basic structure.
let test_basic () =
Alcotest.(check int) "same ints" 42 (21 + 21)
let suite = [
"basic", `Quick, test_basic;
]
let () = Alcotest.run "MyLibrary" [
"suite1", suite;
]
Add to dune-project package stanza:
(depends
; ... other deps ...
(alcotest (and :with-test (>= 1.7.0)))
(eio_main :with-test) ; if using Eio
)
(test
(name test_mylib)
(libraries mylib alcotest))
For Eio-based libraries:
(test
(name test_mylib)
(libraries mylib alcotest eio_main eio.mock))
If your library uses Eio, prefer using Eio's mock infrastructure for testing. This provides:
To understand mock APIs, fetch Eio sources:
mkdir -p third_party
cd third_party && opam source eio && cd ..
Key files to study:
lib_eio/mock/ - Mock implementationstests/ - Example test patternsCommon mock modules:
Eio_mock.Backend - Mock backend for testingEio_mock.Clock - Deterministic clockEio_mock.Flow - Mock flows/streamsEio_mock.Net - Mock networkEio_mock.Fs - Mock filesystemSee templates/test_eio_mock.ml for a complete example.
let test_with_mock_clock () =
Eio_mock.Backend.run @@ fun () ->
let clock = Eio_mock.Clock.make () in
(* Your test using the mock clock *)
Eio_mock.Clock.advance clock 1.0;
Alcotest.(check bool) "time advanced" true true
let () = Alcotest.run "MyLibrary" [
"eio-mocks", [
"mock clock", `Quick, test_with_mock_clock;
];
]
For tests that need real I/O (use sparingly):
let test_real_io () =
Eio_main.run @@ fun env ->
(* Use env#fs, env#clock, etc. *)
()
Eio_mock.Fs for mocked filesystemEio_mock.Net for mocked networkingEio_mock.Clock for deterministic timeproject/
├── lib/
│ └── mylib.ml
├── test/
│ ├── dune
│ ├── test_mylib.ml # Unit tests (with mocks)
│ └── test_integration.ml # Integration tests (if needed)
└── third_party/ # Fetched sources for reference
└── eio.*/
# Run all tests
dune runtest
# Run tests verbosely
dune runtest --verbose
# Run specific test
dune exec -- test/test_mylib.exe
This skill should be used when the user asks to "create a slash command", "add a command", "write a custom command", "define command arguments", "use command frontmatter", "organize commands", "create command with file references", "interactive command", "use AskUserQuestion in command", or needs guidance on slash command structure, YAML frontmatter fields, dynamic arguments, bash execution in commands, user interaction patterns, or command development best practices for Claude Code.
This skill should be used when the user asks to "create an agent", "add an agent", "write a subagent", "agent frontmatter", "when to use description", "agent examples", "agent tools", "agent colors", "autonomous agent", or needs guidance on agent structure, system prompts, triggering conditions, or agent development best practices for Claude Code plugins.
This skill should be used when the user asks to "create a hook", "add a PreToolUse/PostToolUse/Stop hook", "validate tool use", "implement prompt-based hooks", "use ${CLAUDE_PLUGIN_ROOT}", "set up event-driven automation", "block dangerous commands", or mentions hook events (PreToolUse, PostToolUse, Stop, SubagentStop, SessionStart, SessionEnd, UserPromptSubmit, PreCompact, Notification). Provides comprehensive guidance for creating and implementing Claude Code plugin hooks with focus on advanced prompt-based hooks API.