The diagnosis relies mainly on semen analysis. If the semen is abnormal, other tests will be needed to determine what is causing the azoospermia. For example, endocrine tests can be done to find out the levels of various hormones needed in the sperm production process; ultrasound examinations can clarify the presence of swellings compressing the vas deferens and identify abnormalities in the vas deferens and physiological structures; if azoospermia is suspected to be caused by genetic abnormalities, genetic testing can be used to clarify the diagnosis; testicular biopsy can accurately detect sperm production in the testes, but it is an invasive test and is chosen with caution.