Suspending the machine, shutting down, powering off or external usb disks, will aborts the tests and must be restarted.
maybe some spezial drives will retain the test progress which depends on the disk firmware, controller behavior, and power state handling but i don't think so, and the most consumer drives will aborts and restart
When a smartctl command is issued, its effects persist until explicitly changed or until the system is powered off. If the system is powered off, the drive will retain the state set by the smartctl command when it was last used. This means that any ongoing test or command will be interrupted and need to be restarted after power is restored.
Invoking hdparm with the query option is known to wake-up some drives. In this case, consider smartctl provided by smartmontools to query the device which will not wake up a sleeping disk.
Short: runs tests that have a high probability of detecting device problems
Use cron to run tests at times when the system is unlikely to be suspended/shut down, etc., so schedule tests for times when the system is stable, and check logs afterward to ensure completion
From @frostschutz comment & answer:
You can try your luck with selective self-tests.
I switched from long selftests to select,cont tests. It's like the long selftest, but only one slice of disk at a time. So while the long selftest may take well over a day (with an otherwise busy 3TB disk), the selective test can run every night when the server is the least busy and actually finish, without harming performance in the more busy hours.
So basically you would be distributing a monthly long self-test of the entire disk, to a nightly selective test that still covers the entire disk over the course of a month...