Diagnosing power supply issues?
Is there a way to test power supply input and output to find out if
  and when a power supply fails or is failing?


There is a way if you had an oscilloscope, you could monitor the voltage rails and the PG signal.

In my mind there are two problems that could happen:

1) The power supply has some kind of fault and drops out 
2) A component in the system shorts out the supply and the voltage drops, then the supply turns off momentarily

You may be able to monitor the rails with a scope and trigger if the voltage falls below the recommended value. If the voltage falls and you know what rail its on this could help you determine if its the supply or a component. I would think that if it's a component the rail would fall below its recommended tolerance, then you would see the PG signal fall. Knowing which rail may also help, It is my understanding that most supplies have separate regulators for each voltage rail, so a hard drive or fan's voltage rail (like +5V) would most likely be separate from the motherboard


Source: https://www.lifewire.com/power-supply-voltage-tolerances-2624583


  The ATX specification defines the Power-Good signal as a +5-volt (V)
  signal generated in the power supply when it has passed its internal
  self-tests and the outputs have stabilized. This normally takes
  between 0.1 and 0.5 seconds after the power supply is switched on. The
  signal is then sent to the motherboard, where it is received by the
  processor timer chip that controls the reset line to the processor.
  
  The ATX specification requires that the power-good signal ("PWR_OK")
  go high no sooner than 100 ms after the power rails have stabilized,
  and remain high for 16 ms after loss of AC power, and fall (to less
  than 0.4 V) at least 1 ms before the power rails fall out of
  specification (to 95% of their nominal value).


Source: https://en.wikipedia.org/wiki/Power_good_signal