context: Men need a lot of different body parts working the right way -- from the brain and glands that control hormones to blood vessels and the penis -- to get and keep an erection. Because of that, erectile dysfunction, or ED, can have a lot of causes. Some of them are physical; others are mental and emotional. Physical reasons for ED range from heart disease and diabetes to high blood pressure and obesity. Damage to your nerves or arteries can cause problems with erections, too. Lack of exercise, drinking, and smoking can lead to problems. On the mental and emotional side of things, anxiety, depression, and stress all play a role. Relationship issues can also be a factor. With so many possible causes, your doctor has a number of tests he can use to figure out the best treatment for you. This one's not actually a test, but your doctor will likely start with questions about your medical and sexual history. The reason is simple: He wants to better understand how ED affects you and see whether there might be a clear cause for it. When you talk about past surgeries, medicine you take, injuries, and lifestyle choices, your doctor can learn about diseases or other issues you might have that might lead to ED. By asking about your sexual history -- your relationships, sex drive, if you ever get erections -- he can begin to figure out whether the problem is more likely to be physical or mental. Be honest with your doctor; he can't help you if you withhold information. Your doctor will check your penis and testicles to make sure they look normal and their nerves work as expected. He may also look for hair loss and larger-than-normal breasts. Both of these can be signs that you have a hormone problem. He may also: Check your pulse at your wrists and ankles to see whether your blood flow is normal Listen to your heartbeat to make sure it sounds right Take your blood pressure Based on your physical exam as well as your medical and sexual history, your doctor may want to order certain blood or urine tests. He'll use these to check for problems that can lead to ED, such as: Diabetes Heart disease Kidney disease Hormonal problems such as low testosterone One type of blood test can check your thyroid function. A butterfly-shaped gland in your neck, it has a lot of jobs to do. One of them is to help with the flow of sex hormones. This test can check whether it's working right. Usually, men have 3 to 5 erections during the night as they sleep. Your doctor may use an overnight erection test to see whether you're able to get an erection. For this test, you will place a device around your penis before you go to sleep. It measures how many erections you have and how strong they are. A simpler version of this test uses a special plastic ring around your penis. If you get an erection, the ring breaks. If the test shows that you can get erections, it's more likely that the ED is caused by something mental or emotional. An injection test is also called an intracavernosal test. Your doctor injects a medicine into the base of your penis that should give you an erection. If you don't get one, you may have a problem with blood flow to your penis. Sometimes called Doppler ultrasound, this is another way to check blood flow to the penis. It may be used along with the injection test. Your doctor takes a device that looks like a wand and holds it over your penis. It uses sound waves to create a video of your blood vessels so your doctor can look at blood flow. If it looks more likely that a mental or emotional issue is the source of the problem, your doctor will ask you standard questions about your mental well-being. They help him check for depression, anxiety, and other common causes of erectile dysfunction. If you have a regular sexual partner, your doctor may ask to talk to the two of you together. This can help him learn more about your relationship and how it might affect your ability to get and keep erections.