Skip to the content.

Testing

Tether is two apps on two phones that must keep understanding each other, plus a shell helper and a second client. The tests exist so you can change any of it without breaking the others, losing someone’s messages, or publishing something private. Run them before every commit; CI runs the same set on every push and pull request.

One command

tools/test-all.sh            # everything below, except the on-device checks (a few minutes)
tools/test-all.sh --quick    # Android unit tests and the Swift package (about a minute)
tools/test-all.sh --no-ios   # without the iPhone app build and its tests (Linux, or no Xcode)
tools/test-all.sh --no-ui    # everything except the iPhone UI tests

It runs, in order: whitespace and script syntax, the privacy scan, the Android unit tests (A54 app, helper, shared core, Android client) with lint and release builds, the Swift package tests, the iPhone app build, the iPhone app unit tests and the iPhone UI tests (on a throw-away simulator it creates and deletes; without an iOS Simulator runtime the UI tests are skipped with a note). It needs JDK 17 and the Android SDK, and on a Mac Xcode and XcodeGen (BUILD.md).

What each suite protects

Suite Where Run alone What it pins
Protocol contract protocol/fixtures/, android/core/src/test, ios/TetherCore/Tests/.../ContractTests.swift ./gradlew :core:testDebugUnitTest, swift test --filter Contract Every message body as it crosses the link, read by both implementations; old-app variants (fields missing) and newer-app variants (unknown fields) still accepted; message types identical in Kotlin, Swift and PROTOCOL.md §5
TetherCore (Swift package) ios/TetherCore/Tests cd ios/TetherCore && swift test Handshake and record layer including tampering, replay, wrong keys and malformed frames; crypto and framing vectors shared with Kotlin; playout buffer invariants on seeded random traces and measured traces; audio route menu and engine restart rules; number grouping per country; tel: / tether: parsing; one-time codes and links in texts; reconnect back-off
iPhone app ios/TetherTests xcodebuild test -scheme Tether -destination 'id=<simulator>' -skipMacroValidation Saved data written by released apps keeps loading (Fixtures/snapshot-v1.json), a damaged file is kept aside, never overwritten; every incoming message updates the model correctly, and sync.ids never deletes local history wrongly; links never dial without a tap; the Link log stays capped and free of numbers
iPhone screens (UI tests) ios/TetherUITests xcodebuild test -scheme TetherUI -destination 'id=<simulator>' -skipMacroValidation The real screens in the Simulator with the demo data: every tab, opening a conversation (and Back), search, selecting and the bulk actions, the Unread filter, a bubble’s menu (Copy, React, Select Text, Forward, Select, Delete), compose and send, contacts and Favourites, the + menu, Recents and its menu, the Keypad and its call button, the call screen’s buttons, the busy / failed / no-audio calls, the Link tab’s sections, pairing (scanner, manual code), the problem report, tel: and pairing links, Persian right to left (section “iPhone UI tests”)
A54 app android/app/src/test ./gradlew :app:testDebugUnitTest Safety: debug hooks accept only +10000000001…9, test clients can never touch a real call, a test transport is always dry; no Bluetooth link security (LinkSecurityTest); link policy and wake rules; GATT chunking; Share VPN request parsing; uplink buffer, capture timing and per-vendor silence choice
Android screens (both apps) android/app/src/test/.../screens, android/client/src/test/.../screens ./gradlew :app:testDebugUnitTest --tests 'app.tether.screens.*', ./gradlew :client:testDebugUnitTest --tests 'app.tether.client.screens.*' Every Activity in each manifest opens, resumes and closes without a crash, with no data, in English, Persian (right to left) and Turkish. The screens driven tap by tap on the JVM (Screen tests): the phone’s main screen (setup steps, pairing QR, mic setting, link log, problem report, update check), dial pad (keys, one Call button per SIM, carrier and secret codes, recents), call screen with Telecom calls in every state (which call shows, local and bridged controls, call waiting, swap, SIM choice), call notification (#43) and missed calls; the client’s five tabs, a tap on a conversation opening it, selecting, the thread’s bubbles and link colours (#34), the call screen (busy, failed, no audio), USSD, scheduled, starred, folders, chips, pairing and tel: links
Helper android/helper/src/test ./gradlew :helper:testDebugUnitTest The helper’s mutual challenge-response login (protocol §6): wrong token, impostor helper, replay, malformed frames; the token never crosses the socket
Android client android/client/src/test ./gradlew :client:testDebugUnitTest Its real session against a simulated Android phone; every synced message; call-state rules (hang-up guard, call waiting, “elsewhere”); reconnect and REJECT reasons; playout traces identical to TetherCore’s
Privacy tools/check-private.sh tools/check-private.sh [--all] Nothing from your local config, no home paths, device ids, Bluetooth addresses, personal e-mail addresses, commit trailers or assistant names in a change or commit message
Feature map & coverage protocol/features.json, tools/coverage-floors.json python3 tools/check-features.py, python3 tools/check-coverage.py --android --swift Every protocol message, Android screen and listed feature has real passing tests (check-features.py), and line coverage stays above the monotonic floors (check-coverage.py)

The Android commands run in android/ with JAVA_HOME set to a JDK 17; the Swift ones need full Xcode (DEVELOPER_DIR=/Applications/Xcode.app/Contents/Developer when xcode-select points at the Command Line Tools).

Screen tests (Android)

The two Android apps’ screens run on the JVM with Robolectric: no emulator, no phone. They are part of :app:testDebugUnitTest and :client:testDebugUnitTest, so tools/test-all.sh and CI’s Android job run them (about half a minute more on a Mac). The apps build their views in code, so the tests find views as a user does: by the text on them (taken from the string resources, so they hold in every language) or by their TalkBack description, and tap them (Screens.kt in each app’s screens test package).

On-device checks

Automatic tests cannot see Bluetooth, the phone network or audio hardware. With the Android phone attached (USB, or over Wi-Fi: with TETHER_ANDROID_SERIAL set and the phone not on the cable, tools/lib.sh connects to it over the network when adb can reach it there, see tools/local.env.example):

tools/device-test.sh             # test-line calls (answer, decline, remote hang-up, outgoing), a dry sync, phone tools
tools/device-test.sh --iphone    # also one auto-answered test call through the linked iPhone (it rings the iPhone)
tools/device-test.sh --ui        # also the Android phone's own screens on the test line (it taps the screen)

--ui drives the Android phone’s call screen and dial pad the way a person would, with adb shell input tap on what uiautomator dump shows: two test calls ring (+10000000001, +10000000002, with dbg.sh only none so the iPhone stays quiet; only off always runs at the end, even on Ctrl-C), the first is answered from the notification shade, the call screen must show Mute, Keypad, the audio route, Hold, End and a running duration; Mute is checked in Telecom (dumpsys telecom: reported “unknown” when the phone’s Telecom does not say), the keypad’s “1” must reach Telecom (playDtmfTone in logcat within 2 s); the second call shows Decline, Hold and answer, End and answer, Hold and answer puts the first on hold, Swap changes them over, both end (Telecom’s mCalls empty, Tether counts 0 calls, no call notification left); last, the main screen’s “Keypad and recent calls” opens the dial pad with its digits and a Call button per SIM. Run it before tagging a release, with the phone unlocked, screen on, face up and not in a call: it is skipped (never unlocked) when the phone is locked or dark. Buttons are found by their labels in every language the app has (English, Persian, Turkish, read from res/values*/strings.xml), so it works on a phone in any of them. It prints nothing from the screen: the dial pad’s recent calls are real ones, so only their rows are counted. The parsing lives in tools/android-ui.py (its selftest, against hand-written dumps, runs in tools/test-all.sh and CI); a new button on the phone’s call screen or dial pad gets a check there and in device-test.sh.

Both use only Tether’s self-managed test line and test numbers: no real call or text, nothing written to the phone’s call log, contacts or messages. Install the builds you want to test first (BUILD.md). For call audio, tools/dbg.sh loopback_call prints the full figures (ring latency, frames, codec times, jitter, helper statistics), and the iPhone’s Link log has the matching line from its side.

Some things need a person: hearing call audio on a real call, Bluetooth headsets and car kits, notifications and their look. CONTRIBUTING.md lists what to report.

iPhone UI tests

ios/TetherUITests drives the iPhone app’s real screens in the Simulator: it taps, types, holds and swipes like a person and checks what shows. Every test starts the app fresh with the Debug demo data (ios/Tether/App/DemoData.swift): made-up conversations, contacts and calls, never a real link, nothing saved. -TetherDemoLinked makes the screens act as if the Android phone were linked (nothing is sent anywhere), -TetherDemoNoAnimations turns animations off; the other -TetherDemo… arguments open the call screen, a busy or failed call, the no-audio notice, the problem report.

cd ios && xcodegen generate
xcrun simctl create tether-ui "iPhone 17"     # prints the simulator's id; delete it afterwards
xcodebuild test -project Tether.xcodeproj -scheme TetherUI -destination 'id=<id>' -derivedDataPath build-test -skipMacroValidation
xcodebuild test … -only-testing:TetherUITests/MessagesUITests/testTappingAConversationOpensItAndBackReturns   # one test

In Xcode: the TetherUI scheme, ⌘U. The suite takes a few minutes; tools/test-all.sh --no-ui skips it.

On CI (the Apple job) the iPhone unit tests run a failed test again up to twice (-retry-tests-on-failure -test-iterations 3): CallKit answers on its own schedule on the slower runner, and a real regression fails all three runs. The UI tests run once (about 25 minutes there). When either fails, “iPhone test failures” prints every failed test with its assertion message, so the log says why without downloading the result bundle. CI’s Simulator is older than a current Mac’s: a toolbar button’s enabled state, for one, is only reliable looked up as a button (assertOff in UITestSupport.swift).

Writing one: subclass TetherUITestCase (UITestSupport.swift): launch([...]) with the demo arguments the flow needs, then tap, wait, waitGone, hold, scrollTo, dismissDialog. Find elements by accessibility identifier (conversation.<thread>, bubble.<id>, incall.end, …), added in the view with .accessibilityIdentifier, which changes nothing a person sees; English labels are fine for system buttons. Never a fixed sleep: wait for the element the next step needs. If a flow needs data the demo does not have, add it to DemoData.swift behind a launch argument.

Rules for new code