A thermocouple is a device that measures temperature by creating a voltage difference between two dissimilar metals. In a water heater, the thermocouple is used to sense the temperature of the water and send a signal to the gas valve. If the thermocouple fails, the gas valve will not open and the water heater will not be able to produce hot water.
There are a few different ways to test a thermocouple on a water heater. One way is to use a multimeter. Set the multimeter to the millivolt (mV) setting and touch the probes to the two terminals on the thermocouple. The multimeter should read a voltage of between 20 and 30 mV. If the voltage is below 20 mV, the thermocouple is likely defective and needs to be replaced.