TL;DR while experts have varying opinions on whether you can drink coffee before a blood test or not, the rule of thumb is to know what kind of fast you'll need to do. Some allow coffee (and even eating), while others will be better off without both. The best way to know is to ask the medical professional prior to the test to eliminate any doubts!
You’re a coffee lover. Coffee’s part of your morning routine.
But what if you have to take a blood test first thing in the morning? Can you still have your caffeine fix?
This seems to be the million dollar question for many. So today, we’re embarking on a mission to find out what the real deal is.
Why fast before blood tests?
WebMD answers the question about why one needs to fast: 
Nutrients in food and drinks go into your bloodstream and can change things measured by the tests, skewing your results. For instance, if you eat or drink before a fasting blood glucose test, your blood sugar probably will be higher than if you hadn’t had anything. When you’re fasting, doctors get a baseline result so tests can be compared to give a true picture of your sugar levels over time.
Can you drink water before a blood test?
Registered nurse Kathy Reutter writing at One Medical, says many people mistakenly think they need to avoid water during fasts.  Not so, she says. In fact, drinking enough water may help you feel better during a fast and also plump the veins for an easier blood draw by the phlebotomist. She states that blood is about 50 percent water.
Blood work and coffee
But what about coffee? Is drinking it acceptable when fasting?
Doctors keep telling patients that it’s all right to have black coffee before fasting blood work.
However, if you go through various online reports, you’ll note one thing - THEY SAY DIFFERENT THINGS! It seems that jury’s still out on this one.
So here’s the game plan. We’ve taken the liberty to put together what various reports say and we’ll try to come up with a conclusion. Wait 'til you get to the end of this article for the verdict.
How about starting off with good news for coffee lovers? According to William Kormos, M.D., the Editor in Chief of Harvard Men’s Health Watch, it’s okay to drink water, plain coffee, or black tea. 
A 2005 study in The Annals of Pharmacotherapy found that one 6-oz cup of black coffee consumed an hour before the test led to very little (“clinically insignificant”) changes. However, if results turned out to be borderline, it may be worth retaking the test sans coffee. [4, 5]
If you forget and have some coffee with cream and sugar or even a meal the morning of a cholesterol test, don’t panic just yet. CBS News reports that when researchers examined data from 209,000 participants in one study with fasting times ranging from one to 16 hours, there were small differences. 
This article on Livestrong seems to contradict everything else about a fasting blood test: 
“While you may consider black coffee little more than water, drinking it causes you to absorb caffeine and other organic compounds into your bloodstream. You need only plain water, without added vitamins, flavoring or carbonation, to achieve the correct fluid and electrolyte balance in your blood chemistry.”
According to Livestrong, "a fasting glucose test measures the level of glucose in the blood during a fasted state," so you need to avoid food and beverage intake for at least 8 hours. 
“Fasting is defined as eating and drinking nothing but water. These narrow parameters allow lab technicians and physicians the greatest diagnostic margin by introducing no dietary variables into the procedure. While you may consider black coffee little more than water, drinking it causes you to absorb caffeine and other organic compounds into your bloodstream. You need only plain water, without added vitamins, flavoring or carbonation, to achieve the correct fluid and electrolyte balance in your blood chemistry. In some instances, your doctor will ask you to avoid only certain foods, beverages or medications before a test.”
Medical News Today agrees with Livestrong, saying that “coffee affects digestion and can also affect the results of a blood test. As such, people should not drink coffee before a fasting blood test.” 
Guidelines on common blood tests
It depends to some extent on what test is being performed, but for many that require fasting, intake of non-carbohydrate containing liquids a few hours before blood work will not impact results.
Luckily, there are various guidelines available to know whether it’s safe to go with black coffee before heading to the clinic, or just steer clear altogether.
The British National Health Service has the following fasting guidelines on some common tests: 
Fasting glucose blood test: This test helps a doctor diagnose a patient for diabetes, which is caused by having too much sugar in the blood. For this test, one needs to abstain from all foods and drinks except water for eight to 10 hours beforehand.
Iron blood test: These are usually taken in the morning before eating anything, and also after avoiding iron or iron-containing pills from 24 hours beforehand. This test can help diagnose anemia, or having too few red blood cells, a condition that can be caused by iron deficiency.
Lipid profile or cholesterol test: This is one test that doctors require many people to get with today’s diet of high-fat and high-cholesterol foods. The doctor will probably tell you to drink only water and not to eat anything for up to 12 hours before the phlebotomist draws your blood. Doctors test for what is called good cholesterol, bad cholesterol, the total number of cholesterols and triglycerides or other types of fats.
Medical News Today also has additional guidelines, as follows: 
Gamma-glutamyl transferase test: this is a test to diagnose any liver disease. While fasting for food is not necessary with this test, patients are advised not to consume alcoholic beverages nor smoke 24 hours before the test.
Comprehensive metabolic panel, which doctors order as part of a yearly physical to test check your blood sugar, electrolyte and fluid balance, kidney function and liver function.
Renal function panel: Tests to see how well the kidneys are working. Typically, people are asked to fast for 8 to 12 hours before these tests.
Vitamin B12 test: Doctors order the vitamin B21 test to measure the amount of this vitamin the blood. This test helps diagnosis one type of anemia and other problems. Your doctor will likely ask you again all the medications you take because some drugs can interfere with this test.
Drinking coffee and eating are OK before some blood tests but not others, and some doctors say any black coffee at all before is OK even before a cholesterol test as long as you don’t add cream or sugar.
But if you still find yourself in doubt, it’s best to ask a medical professional. In fact, upon recommendation of a blood test, you should double-check with your doctor. They may be ordering tests that they haven't told you about — tests that do require fasting.
Careful about falling asleep at work or you could become an Internet meme like this poor fellow.
Unless you work outdoors or indoors in a job where you are physically active all day, it can be difficult for some people who have desk jobs to stay awake at work without caffeine.
Maybe the most important thing you can do to make sure you don’t nod off at work is to get a good night of sleep, at least 7 to 8 hours, at a regular time every night. Boredom can also cause you to nod off. Other than getting a good night’s sleep and having a fascinating job, there are things you can do to stay awake.
How do investment bankers stay awake on their 18-hour shifts?
Investment bankers work such long hours that many resort to chemical stimuli. There have been rumors of methamphetamine and cocaine use among investment bankers to burn the midnight oil. Other investment bankers take Ritalin or Adderall, which are given to children with ADHD but which are stimulants for adults. But the mainstay is probably coffee, energy drinks, and other concoctions containing caffeine.
Some law students spend 60 hours a week studying. Those who’ve been through law school advise prospective students to leave the Xbox at home so they’re not tempted with potentially ruinous distraction. How do law students get energy to study so much?
One thing many law school students do not do is party and socialize a lot. This has a doubly salutary effect because the time spent not partying is time they can spend studying. And then they are not out of sorts, hung over or over-tired the next day from partying.