What is the best way to measure op amp input and output impedance versus frequency?
What's wrong with studying the data sheet (and believing it) - it tells you virtually everything (unless the data sheet is not available). Here's what the AD8605 has to say about itself: -



The graph at the top tells you what the output impedance is for various gain settings. Read between the lines for other gain settings.

The input impedance is very high (resistive DC) but for AC it tells you what the input capacitance is and from this you can work out the impedance.

I think most modern op-amps will give you this information.

If you need to measure output impedance then set up a particular circuit of interest to you and apply loads to the output and measure by how much the output voltage drops - this can be used to calculate the output impedance.

For input impedance you can apply a signal in series with a known "high value" component and see how much the output reduces when that high value component is in-circuit. Adjust the high value component until the output signal drops to half and you have almost discovered what the input impedance magnitude is. I'd use a resistive decade box and I'd recognize that the potential divider formed by the box and the input pin is formed by a resistor (decade box) and capacitor (input pin) and make the appropriate math adjustment to calculate the capacitance. Of course, if you have a capacitance decade box then this saves doing the math.

It all depends on the circuit as well. If you are interested in an inverting amplifier input impedance then the impedance is going to be nearly all resistive.