Basic workflow

Version 0.2.0 Updated Nov 27, 2025

CmdMox follows a strict record → replay → verify lifecycle. First declare expectations, then run your code with the shims active, finally verify that interactions matched what was recorded.

The three phases are defined in the design document:

  1. Record – describe each expected command call, including its arguments and behaviour.
  2. Replay – run the code under test while CmdMox intercepts command executions.
  3. Verify – ensure every expectation was met and nothing unexpected happened.

These phases form a strict sequence for reliable command-line tests.

A typical test brings the three phases together:

cmd_mox.mock("git").with_args("clone", "repo").returns(exit_code=0)

my_tool.clone_repo("repo")
# Replay begins automatically before the test function executes; verification runs during teardown.