Well, sometimes it is a bit of a guess, but how the metal is used, and knowing the properties of some of the likely metals helps. If it obviously a cast piece, that narrows it down to the metals most likely to be cast. Disclaimer: Nearly all metals CAN be cast, but some are difficult to cast, and then some are economical to cast, and exhibit properties as cast that are desirable for certain applications.
Spark test can be invaluable for getting an idea for what it is, but is not the be-all end-all, and obviously, you will need to try grinding on a location that will not be seen, or effect the part function. A magnet, as previously discussed, can narrow the field quite a bit. Normally, application, plus a few physical traits will get you by. If you really need to know what it is, get chummy with a good scrap yard. Many these days have a portable XRF gun and will shoot your sample for a fairly positive ID.