Most often this can be based on the story alone. If there is doubt, then a urine specimen can be examined by the doctor using a testing dip-stick, or by a laboratory, using a microscope, special stains to show up bacteria, and trying to grow (culture) any bacteria that may be there. Growing the bacteria allows the doctor to find out which antibiotic will best eradicate it.
Further tests to rule out any possible underlying cause for urinary infection, either after one attack in a male or multiple attacks in a female may be also done. This may involve ultrasound scans, X-Ray of the kidneys and bladder using a dye injected into the blood vessels (intravenous urography), or looking into the bladder using an endoscope (cystoscopy).