The most accessible and common cause of a malfunctioning water heater is the thermocouple. That doesn't mean that something else isn't causing the problem, but the easiest component to test before anything else is the thermocouple. Although there are some specialised tests with dedicated equipment that a professional might carry out, there is one basic test that virtually any homeowner will be able to accomplish.
Remove the thermocouple access panel with your flat-blade screwdriver by turning the screws in an anti-clockwise direction.
Light the pilot light as the per instructions on your specific model of gas water heater.
Turn the top control knob to "Off" and begin to count to 30 or look at the seconds on a watch and wait for 30 seconds.
Listen for the safety shut-off in the control valve to noticeably click off after 30 seconds. If the valve clicks off before the count is finished, the thermocouple is broken and it must be replaced.
Another foolproof way to test a bad thermocouple is to just replace it with a new one. If the water heater works, than you know for a fact that the thermocouple was faulty. If the water heater still does not heat water, than you know for certain that there is another problem.