If something is wrong with your Mac, either you or the tech repairing your Mac will need to access the special diagnostics mode. You can do this by restarting your Mac and holding the D key. The results could give you some insight into the problem. See https://support.apple.com/en-us/HT202731 for details.
Now if you're having problems with your Mac and you think it's the hardware and you're at the point where you're just about either to call Apple or go to the Genius Bar, one of the things you may want to do is run Diagnostics Mode. This could tell you some things about what might be wrong with your Mac hardware.
Now go to this page here and this will tell you how to do it. But I can walk you through the steps. It's pretty simple. But do note that it's different depending upon the age of your Mac. If it is a Mac from before June 2013 then you've got a different set of instructions here. Very similar but slightly different.
Basically what you're going to do is restart your Mac and hold the D key down. Let me show you. So to access diagnostic mode I'm going to restart the Mac andI'm going to hold the D key down. Going to confirm here. Then the D key should tell it to restart in this special diagnostics mode. Now this won't work if you've had your firmware password set. If you don't know what that is then you probably haven't set it. But if you have then you need to remove your firmware password.
Now you can see this is the beginning of Diagnostics Mode. I first need to choose a language. Then it starts. It takes about three minutes on this Mac but on other Macs it may take longer. So here you can see it says there are no issues found. Now if it had found issues it would provide you with these reference codes here which you could do searches for online or simply report to Apple when you call in to them for help or when you go and visit the Genius Bar.
At this point here I'm done and I can simply restart or shut down my Mac. Now back at this web page from Apple you can see here an example of something that may come up. For instance, in this example an issue with the power adapter, some WiFi issues and it gives you some reference codes here. Then it gives you the ability to run the test again. Obviously I didn't see that because no issues were found.
You can look at the rest of this page here and see there's some shortcuts that you can use. Like, for instance, run test again, Command R. Or restart is R and S. So take a look through this to see what you might be able to get from running this hardware test.
But in general if somebody tells you to run the hardware test or the Diagnostics Test on your Mac this is what they mean and this is how to do it.
Here’s Apple’s official page: How to use Apple Diagnostics on your Mac