On Linux these can executed with "smartctl", which can also be used to read the error logs after the tests finish. The long test can take almost a day on big HDDs, while the other tests take only a few minutes.
After I had some problems with a bad HDD, I have begun to always execute all the SMART tests whenever I buy a HDD. Of course, if any test fails, the HDD must be returned immediately and the vendor cannot refuse to replace it when the request is backed by the failed SMART acceptance tests.
This is a good habit, because even if such events are very rare, I have still encountered a few HDDs that have failed the tests, so I have returned them and I have received other good HDDs.