Hi,
Since you mentioned a huge test, I am assuming you must be a young school or college going person. The stomachache that your are having can be due to several reasons including
gastritis, peptic ulcers, esophageal spasm or any problem in liver or
gall bladder or
pancreas. Sometimes, stress can precipitate ulcers. In order to evaluate you appropriately, more detailed history (such as onset , location, progression, duration, intensity and quality of pain, any relieving or precipitating or aggravating factors, associated symptoms,
vomiting,
diarrhea, blood is vomitus stools, changes in bowel movement, any urinary complaints, etc) and a physical exam will be required. If your pain alters with food, it is more likely to be a gastrointestinal cause such as ulcer.
However, at your presumably young age, ulcer is less likely.
Since you have a test coming up, you may try over the counter
pantoprazole 40 mg (adult dose) once a day half an hour before meal (twice a day for more severe symptoms) and
vitamin B supplement once a day. That should give some relief. Also try meditating and relaxing if you have any stress. Avoid taking analgesics for pain . Avoid coffee, chocolate and spicy food. Milk, yogurt, vanilla icecream and mild food may soothe your gastric lining. Avoid overeating. Drink lots of water if you need to stay awake for studying.
My recommendation is to get yourself evaluated at your earliest convenience. However, with above advice and assuming no emergency, you should be able to take your test though. All the best.