How do they test for ulcers of stomach?

Endoscopy. Has largely replaced less clear contrast barium swallows. Also, tests for helicobacter pylorii can be done.