Browse the docs

Testing a macro

Shows how to save a run as a test, run tests and checks, and know a macro still works after an edit or a macOS update.

A macro you rely on should tell you when it stops working. Switchboard gives you two kinds of proof, because two different things break.

  • A test proves the logic. Given these inputs and this world (the front app, the clipboard, the variables, the clock), the macro gives back this value, reaches these steps and sets these variables. It runs sealed: nothing touches your Mac, so it is safe to run a hundred of them at once.

  • A check proves the world. The elements, menu items, apps, shortcuts, extensions, called macros and hotkeys the macro depends on are still there. Checks look; they never click. This is what a macOS update breaks.

The easy way: save a run as a test #

You do not have to write a test. Open Activity, select a run that worked, and choose Save as Test. Switchboard builds the test from the run: the inputs it had, the front app and clipboard it saw, what each step that acts gave back, and what the run returned. A sheet opens to name it and trim it.

By default a test expects only that the run ends fine and gives back the same value. Also check… adds the steps that ran and the variables that were set. Keep tests small: the more a test pins down, the more often an ordinary edit breaks it.

Running tests #

Select a macro and choose Macro ▸ Run Tests (⌃⌘T). The Tests section of the macro lists each test with a dot: green passed, red failed, grey not run. A failed test pins the first thing that was wrong above its trace, in plain words: Expected to give back 'day-412', gave back 'DAY-412'. Open in Debugger steps through the same sealed run.

Next to the tests, the Checks line says what the last check found: 6 of 6 found, or 1 of 6 missing: Send button in Slack.

What a test says #

PartMeaning
InputsThe macro's inputs, as you would pass them to a run.
GivenThe world: front app, window title, clipboard, variables, shared. variables, the clock, the trigger's value.
SamplesWhat a step that would act on your Mac gives back instead, by step.
ExpectHow the run ends, what it gives back, steps it reaches or skips, variables it sets, where it fails.

Steps that only compute (variables, if, repeat, group, return, scripts that only calculate) run for real. Every other step is simulated, even one marked safe for dry runs.

When it runs by itself #

  • After a macOS update, and once a day, Switchboard runs the checks for your enabled macros and names the ones that lost something: 3 macros lost an element after macOS 26.2: Paste ticket, …. It never runs your tests then: tests are your logic, not the system's.

  • Make with AI runs the tests of a macro it wrote before you add it, and shows the dots. A failing test never blocks you; the sheet says so and you choose.

  • Tests travel with a shared macro, and import shows "2 tests" and runs them.

From the command line #

switchboard test --all --checks

See switchboard test. Tests run without the engine, so they work in CI.