Skip to content
CoreMacs
Mac infrastructureChecklist

Running a headless Mac mini for UI tests: displays, sessions and resolution

A Mac mini with no monitor can build code and still fail UI tests or screen capture. This checklist covers the logged-in session, auto-login, dummy plugs versus virtual displays, Screen Sharing, resolution checks and keeping the screen awake.

CoreMacs News Desk·Published ·Last verified ·5 min read
Rear view of a silver Mac mini on a wooden desk, showing its power, Ethernet, Thunderbolt, HDMI and USB ports.

A Mac mini that builds code without complaint can still fail the moment a test needs a screen. With no monitor attached and nobody logged in, UI tests and screenshots can fail in ways that look flaky but are really environment problems. This checklist covers the session, the display, remote access and sleep settings.

Why a missing monitor matters

Compiling does not need a desktop; testing usually does. Apple's archived Testing with Xcode guide, last updated in 2017, says code using AppKit or UIKit must run in an Aqua session, created when a user logs in interactively, and that this includes testing in the Simulator. With no user logged in, an ssh login gets only a command-line session, and xcodebuild run over ssh or from a launch daemon fails; once a user is logged in, the guide says ssh runs work for all test types. A Mac waiting at the login window is not ready; whether tests survive a locked screen is worth testing.

Separately, a Mac with no display attached may give you a different screen size than your laptop, so check the resolution before trusting layouts and screenshots (see below).

The logged-in session and auto-login

Automatic login is the simplest way to get a session back after a power cut or update restart. Apple's automatic login article puts it under System Settings, Users & Groups, "Automatically log in as" in macOS Ventura 13 or later, and under System Preferences, Users & Groups, Login Options in earlier releases.

If the setting is dimmed or does not show the account name, manual login is required. Apple's examples:

  • FileVault is turned on, so every restart needs someone to log in.
  • The Mac is supervised by an organization with a profile that prohibits automatic login.
  • The account uses an Apple Account password to log in; you might then also see a message about encrypted home folders.

Auto-login covers start-up only: Apple notes you may still need to log in after logging out, switching back from another user or locking the screen, or to enter a password when the Mac wakes from sleep or leaves the screen saver.

Dummy plug or virtual display

Hardware dummy plug. A small HDMI or DisplayPort adapter that presents itself as a monitor, so the Mac sees a display with nobody connected. Behaviour can differ between adapters and Mac models, so test the exact plug on your model and macOS version.

Software virtual display. Apple's guide to sharing the screen of another Mac says virtual displays are available only with High Performance connections; you then pick one or two from the Display Type menu and can adjust their arrangement, resolution and colour profile. Because this display belongs to a connection, do not assume it exists when nobody is connected; check before a night-time run depends on it.

What Screen Sharing changes

Some options in that guide change only your view; dynamic resolution changes the remote display:

  • Scaling on fits the whole shared screen on yours; scaling off shows it full size, and you might need to scroll.
  • Dynamic resolution resizes the virtual display to fit your window; it needs a single virtual display in a High Performance connection and can be switched from the View menu.
  • In Screen Sharing settings, the Display option sets the default for computers you have never connected to.

Apple's Screen Sharing setup steps start in System Settings, General, Sharing. Screen Sharing and Remote Management cannot be on together, so turn Remote Management off first, then turn on Screen Sharing and choose users under "Allow access for". Keep dynamic resolution off while watching a run unless your tests tolerate size changes.

Check the resolution the Mac actually uses

Ask the Mac rather than a scaled viewer. A scripting guide on Apple's Education Community reads display details with system_profiler and filters for the resolution line:

system_profiler SPDisplaysDataType | grep "Resolution"

The same guide mentions system_profiler -listDataTypes for other report types. Compare with System Settings, Displays, where Apple's guide to changing the display resolution shows how to pick a size or return to Default. Run the check in the context your tests use, with and without a remote connection, log it at the start of each job and fail early on an unexpected size.

Keeping the screen awake and unlocked

Apple's Lock Screen settings page lists inactivity timers that turn the display off and "Require password after screen saver begins or display is turned off", with a choice of delay. On an unattended test Mac, keep the display awake during runs and set the delay accordingly; if tests pass while you watch but fail overnight, look here first. An unlocked Mac is open to anyone who can reach it, so keep it somewhere controlled.

For the length of a job, caffeinate can hold the display awake. Flags listed in SS64's caffeinate reference include -d (prevent display sleep), -i (prevent idle system sleep), -u (declare the user active, which turns the display on if it is off; without -t it times out after five seconds) and -w (hold until a given PID exits). Given a command, it holds its assertions while that command runs:

caffeinate -d -i ./run-ui-tests.sh

Check man caffeinate on your macOS version for the exact flags. Keeping the display awake is a separate matter from the login state, so check the session on its own.

A short pre-flight checklist

  1. Reboot and confirm the Mac reaches a logged-in desktop without help.
  2. End every Screen Sharing session and confirm, from the kind of job your runner uses, that system_profiler SPDisplaysDataType still lists a display.
  3. Confirm the resolution matches what your tests expect.
  4. Leave it idle past the display-off time and confirm a test still runs.
  5. Repeat after each macOS update.

Sources

Share