MONKEYTESTERDOCS
Docs / Run it locally

Run it locally

Everything on one machine, nothing on the network. Start with the viewer alone to look around, then run the whole stack on one Mac with your phones plugged in.

The lab splits MonkeyTester across a Linux host and a Mac, which is why the other setup pages talk about LAN addresses and pairing tokens. None of that is needed on one machine: every service listens on 127.0.0.1, and a service on loopback runs without a token.

The viewer alone (any Linux or Mac)

Enough to sign in, look at Settings, and write tests. It runs no tests: those need a controller and a phone.

Needs git and either Nix with flakes, or Python 3.10+ and ffmpeg (sudo apt-get install -y python3 ffmpeg git on Debian/Ubuntu, brew install python ffmpeg git on macOS — the python3 that ships with macOS is too old).

git clone https://github.com/yurivibes/MonkeyTester.git
cd MonkeyTester
nix run .#tests                               # or: python3 -m unittest discover -s tests -t .
MT_VIEWER_BIND=127.0.0.1 nix run . -- 8089    # or: MT_VIEWER_BIND=127.0.0.1 python3 app.py 8089

Open http://127.0.0.1:8089/ and sign in as admin / admin; change the password in Settings → Configuration → Account (a banner nags until you do). Run it from the repo root: the viewer keeps its state (Run/, Conf/, auth_config.json, build_config.json) next to app.py. Delete those to start over.

Until a controller is added, device lists and runs say "CONTROLLER_URL is not set — register the Mobile Controller in Settings → Plugins → Controller Plugin". That is expected.

The whole stack on one Mac

The Mac owns the phones, so a complete local setup runs everything on it:

ServiceRepoAddressHow it stays on loopback
ViewerMonkeyTester127.0.0.1:8089MT_VIEWER_BIND=127.0.0.1
Mobile ControllerMonkeyTester-Plugin-Mobile-Controller127.0.0.1:8090CONTROLLER_BIND=127.0.0.1 (then CONTROLLER_TOKEN is optional)
Vision model (AI)MonkeyTester-Plugin-AI127.0.0.1:8091serve without --lan (the default)
DIFF pluginMonkeyTester-Plugin-Diff127.0.0.1:8095the default
Build plugin (optional)MonkeyTester-Plugin-Build-Local127.0.0.1:8094PLUGIN_HOST=127.0.0.1 (then PLUGIN_TOKEN is optional)

Requirements

  • An Apple silicon Mac with 16 GB of memory (8 GB works with the smaller model) and about 8 GB of free disk for the model.
  • Xcode, signed in to an Apple Developer team, and Homebrew: brew install python ffmpeg git node, then npm install -g appium && appium driver install xcuitest.
  • For Android phones or Android builds: the Android SDK at ~/Library/Android/sdk and a JDK (brew install --cask temurin@21).

Details for each are on Mac → Install the toolchain.

Clone the repos

mkdir -p ~/Workspace && cd ~/Workspace
for r in MonkeyTester MonkeyTester-Plugin-Mobile-Controller MonkeyTester-Plugin-AI \
         MonkeyTester-Plugin-Diff MonkeyTester-Plugin-Build-Local; do
  git clone "https://github.com/yurivibes/$r.git"
done

Start the services

One terminal each (or a tmux window each). Start the plugins first, the viewer last.

cd ~/Workspace/MonkeyTester-Plugin-Mobile-Controller
CONTROLLER_BIND=127.0.0.1 \
APPIUM_ORG_ID=<TEAM_ID> \
APPIUM_SIGNING_ID="Apple Development" \
APPIUM_WDA_BUNDLE_ID=<your.prefix>.WebDriverAgentRunner \
python3 device_controller.py
cd ~/Workspace/MonkeyTester-Plugin-AI
bin/monkeytester-ai setup
bin/monkeytester-ai serve
cd ~/Workspace/MonkeyTester-Plugin-Diff
python3 diff_plugin.py
cd ~/Workspace/MonkeyTester-Plugin-Build-Local
PLUGIN_HOST=127.0.0.1 python3 build_plugin.py
cd ~/Workspace/MonkeyTester
MT_VIEWER_BIND=127.0.0.1 python3 app.py 8089

Every repo also has a flake.nix: with Nix, nix run in each checkout replaces the python3 … line (keep the environment variables in front). Your team id is under Membership at developer.apple.com/account; the WebDriverAgent bundle id must be one your team can sign.

Check each one answers:

curl -s 127.0.0.1:8090/health   # "appium": true, "adb": true
curl -s 127.0.0.1:8091/health   # "name": "AI"
curl -s 127.0.0.1:8095/health   # "name": "DIFF"
curl -s 127.0.0.1:8094/health   # "platforms": [...]
curl -s 127.0.0.1:8089/health   # "ok": true

Connect them in the viewer

Sign in at http://127.0.0.1:8089/, change the admin password, then open Settings → Plugins. Type only addresses; leave every pairing-token field empty.

  1. Controller Plugin: add http://127.0.0.1:8090.
  2. Test Plugins: add http://127.0.0.1:8091 (shows up as AI) and http://127.0.0.1:8095 (DIFF). Click Configure on the AI row and pick Local model → qwen2.5vl:7b-q4_K_M.
  3. Build Plugin (optional): add http://127.0.0.1:8094, then Configure: the code host (Gitea or GitHub), its URL, a read-only token, and the viewer URL http://127.0.0.1:8089. Add your repo under Settings → Build & Test → Projects. See Build & Test.

Then open http://127.0.0.1:8089/api/status: controller.ok and vision.ok should both be true.

Plug in a phone

Connect an iPhone by USB (trusted, Developer Mode on, unlocked) or an Android phone with USB debugging on, to this Mac. curl -s 127.0.0.1:8090/devices lists it. The first iOS run builds WebDriverAgent onto the phone, which takes a few minutes. See Phones.

Your first run

Put the test cases in your app repo under mt-tests/<case>/ (an INSTRUCTION.txt and at least one test .txt, see Writing tests). Then either:

  • With the build plugin: commit .monkeytester/build-android.sh / build-ios.sh to the app repo (Settings links an example script) and start the run from Build & Test (/build.html): pick the branch, platforms and cases.
  • With an app you built yourself: generate a CI token in Settings → Configuration → CI token and upload the .apk or signed .ipa from the app repo's root (below). It waits for the verdict and exits 0 only if every test passed; the run page shows it live.
export MT_CI_TOKEN=<the CI token>
python3 ~/Workspace/MonkeyTester/ci/mt-submit/submit.py --url http://127.0.0.1:8089 \
  --app app/build/outputs/apk/debug/app-debug.apk --platform android \
  --tests-dir mt-tests --repo <owner/repo> --branch <branch>

Things to know

  • Port 8091 twice: the AI plugin and the ESP32-SENSOR device plugin both default to 8091. If you add ESP32 plugins on the same machine, move one (MTAI_PORT=8096 bin/monkeytester-ai serve, or PLUGIN_PORT for the ESP32 plugin) and add that address instead.
  • Loopback means this machine only. To open the viewer from another computer, drop MT_VIEWER_BIND (it requires a login on any bind, but speaks plain HTTP). To move a plugin to another machine, give it a LAN bind and a token — see Linux host and Mac.
  • Keeping it running: the controller, AI and build plugins ship LaunchAgents (Mac → Start it at login, bin/monkeytester-ai service install, packaging/launchd/ in Build-Local). A LaunchAgent bound to loopback still needs no token.
  • Keychain: signing WebDriverAgent and the .ipa uses your login keychain. Choose Always Allow when macOS asks, or later runs from a LaunchAgent fail to sign.