Relays are used throughout automotive electrical systems. The purpose of a relay is to allow a low-amp circuit to control a high-amp circuit. Relays are just electronically controlled switches. You might find that one relay contains multiple relays inside it. This is common in modern systems. If you're lucky, a wiring diagram and terminal label will be printed on the outside of the relay. This will make your life much easier. If not, try looking for terminals of the same color. This normally means that they are part of the same circuit. This information might not always work for you, but it's done well by me for years now.
There are two basic parts to a relay: the coil and the switch. The coil is the control circuit and is used to activate the switch. It does this using the electromagnetic principle. Once the coil is energized, it creates a magnetic field, which closes or opens the switch. That's worth mentioning here. Some relays are normally closed and the activation of the coil opens the switch instead of closing it. This is where your wiring diagram comes in handy. Testing is fairly straightforward. Just activate the coil and check the resistance of the switch circuit. This video will help explain it.