Move HDD from a MacBook Pro (Mid 2012) model to another MacBook Pro (Mid 2012) model
As long as you're certain the replacement hardware is identical to your original, then yes this will work. One important caveat:
This is something I would not do without testing first. I'd invest in either a USB-SATA drive adapter or a cheap USB enclosure and use that to connect your old laptop's drive to the replacement laptop and see if it comes up as a bootable drive by holding down the option key at startup. If it shows up in the boot manager and successfully boots the system that way then it should be ok to swap it in.
If you're unsure of how to verify if your replacement is the same build as your old laptop I'd recommend using this site: [http://www.chipmunk.nl/klantenservice/applemodel.html/] to do a comparison using the serial numbers of both systems.
If you buy the same model Macbook, then the old hard drive should work perfectly. If it is a different model, things can get tricky. The hard drive has startup files that assume the presence of certain hardware.
One thing that is easy to do, is to use the hard drive in target disk mode before you swap the hard drive. This allows you to mount the hard drive externally, but boot the Mac from it. If the new Mac starts with the old hard drive, then you can safely swap it. If not, then you can return the Macbook.
-Purchase a USB to SATA adapter (example)
-Attach the hard drive to the adapter, and then plug into USB
-Reboot the computer, and hold down the "T" key. A menu will show your external drive. Select it.
Of course, reusing the hard drive also means that you now have a used, three year old drive in your Mac. The data on the old drive is not tied to that drive, and its fairly simple to transfer it. Another option is to purchase an external case for the hard drive, in which case you simply attach the drive whenever you need the data.