Your doctor will use information from your medical history, a physical exam, and tests to diagnose an ulcer and its cause. The presence of an ulcer can only be determined by looking directly at the stomach with endoscopy or an X-ray test.