You may not know it, but your Mac has a built-in diagnostic tool that can help you detect hardware problems before you even take the machine to an authorized service center.
If your Mac was launched in June 2013, this tool is called Apple Diagnostics. It came to replace the old Apple Hardware Test (AHT).
To access it, just restart your Mac by holding the ?D? key (or ?Option + D?, to start the diagnostic system over the internet so it can indicate relevant support articles, for example).
Before starting everything, it is important to disconnect all peripherals from your Mac (contrary to what I did on the video, hehe), except for the keyboard and mouse, leaving it connected to power. In the case of laptops (MacBooks (Air / Pro)), also make sure that the computer is on a flat surface with adequate ventilation.
In my case, thank God, no problem was found. But the screen could indicate something, like this:
Apple Diagnostics can indicate some initial steps to resolve the detected problem, but in most of them you will probably have to take your Mac to an Apple Authorized Service Center or Apple Retail Store.
The procedure is also useful for when you are buying a used Mac and want to make sure that there is no problem with the machine's hardware, even if at first glance it is not apparent. Here's the tip.
(tip from Rodrigo Martins)