I have gotten a disease that may affected my fertility. I’m an unmarried man. Is it permissible for me to get a fertility test to see if I’m sterile? And if I am, so I can tell a potential spouse.
In the Name of Allah, the Most Gracious, the Most Merciful.
In order to get a fertility test done, the sperm sample will have to be provide most likely through masturbation, which is generally not permissible.
However, due to necessity and the mentioned medical reasons it will be permissible. 
And Allah Ta’āla Knows Best
Mufti Arshad Ali
Darul Iftaa, Jaamia Madinatul Uloom (Trinidad)
-  Fatawa Darul-Uloom Zakariyya,. V 6, Pg. 791