How can I tell if my NXT motor is faulty? I pulled my old Mindstorms NXT out of storage (it's been there for a few years). After patching together a test robot, I noticed that my motors behave strangely.

At first, one of the motors did not respond to move commands. After disconnecting/connecting a few cables, another motor stopped working (with a different cable, on a different port). While troubleshooting, the behaviour erraticaly switched between all three motors working (rarely and for a brief time), two not working, or one not working. 

Now it's stable, with one of the motors not working, always the same one, no matter what port I plug it in. I suspect that it may be faulty, however I'm not sure due to the strange behaviour described above. 

Does anybody know how I can test the motors, see which are faulty, if any? Or any other tips troubleshooting this? Thanks.
If the one motor exhibits the same behaviour on any port with any cable and the other motors are working on all of the ports with any cable, then it is safe to say that the problem is definitely with the motor itself.

Make sure you swap cables as well as motors to rule out a faulty cable.

Also, check for signs of corrosion on the pins of the cables, motors and NXT. This kind of erratic behaviour is indicative of poor electrical connections.