Hey bull -
The answer to your question is not short and simple, not easy to post up like I think you want it.
The best way to start with sensor testing is to first get a firm understanding of how the sensor works. You need to know what each wire does, how the sensor operates in relation to the environment it is in (as in, does it energize a circuit, does it open a circuit, does it do it due to heat, noise, voltage, etc.). You need to know the voltage ranges of the sensor. O2 sensors for example range between 0 and 1 volts as their output voltage (going to the ECU). Once you have a pretty good understanding of HOW it works, then you can move to testing it to see IF it works.
The primary way to test is with an O-scope, or with a diag tool that reads the data in live mode and outputs that data to you. That last way is the best as you don't have to interpret the signal on the scope, you are just looking at the voltage swings and the timing on the chart the tool indicates.
This guy does a pretty good job describing the HOW, and a simple way to test basic functionality with a multimeter.
Ratchets and Wrenches.
Many, many other videos you can watch on Youtube that show you how to fully diagnose these with various OBDI packages out there. You are looking for the voltage swings at various RPMs and at certain times (when you up the RPM and as you let the RPMs back down to idle). You need a charting, live data scan tool to do it.
All these tools cost more than the 02 sensor, but of course give you a tool to test many other things. If you are serious about testing various auto components/sensors for a long time, then invest in a good, high dollar scan tool like Autel or something like that. But plan that this tool will cost you in the $2,000 and up range if you want to have a reliable, stable, multi-use tool across many vehicles.