If your Mac was introduced before June 2013, it uses Apple Hardware Test instead.
How to use Apple Diagnostics
- Disconnect all external devices except TarDisk, keyboard, mouse, display, Ethernet connection (if applicable), and connection to AC power.
- Make sure that your Mac is on a hard, flat, stable surface with good ventilation.
- Shut down your Mac.
- Turn on your Mac, then immediately press and hold the D key on your keyboard. Keep holding until you see a screen asking you to choose your language. When Apple Diagnostics knows your language, it displays a progress bar indicating that it's checking your Mac:
- Checking your Mac takes 2 or 3 minutes. If any issues are found, Apple Diagnostics suggests solutions and provides reference codes. Note the reference codes before continuing.
- Choose from these options:
- To repeat the test, click ”Run the test again” or press Command (⌘)-R.
- For more information, including details about your service and support options, click ”Get started” or press Command-G.
- To restart your Mac, click Restart or press R.
- To shut down, click Shut Down or press S.
If you choose to get more information, your Mac starts up from macOS Recovery and displays a web page asking you to choose your country or region. Click ”Agree to send” to send your serial number and reference codes to Apple. Then follow the onscreen service and support instructions. When you're done, you can choose Restart or Shut Down from the Apple menu.
Source: Apple support