Scientists have developed a non-invasive test that can predict whether men with zero sperm counts are capable of fathering children through IVF.
Current methods rely on surgery to find out if a man has viable sperm that can be retrieved for fertility treatment.
The research, in Science Translational Medicine, suggests two biomarkers can identify who will benefit from surgery.
A UK fertility expert said the test, which will take at least a year to bring to the clinic, was "encouraging".
Male infertility is responsible for about half of cases of infertility.
Men who produce no sperm can sometimes be helped to father a biological child through fertility treatment if they have normal sperm that can be extracted surgically.
Others will never be able to father a child naturally and need to use donor sperm.
With current technology, the only way to find out if a man has viable sperm is to carry out surgery to look for sperm in the testes.
The new test, developed by scientists in Canada, has identified two biomarkers in sperm, which can be used to predict whether sperm retrieval will be successful.
Dr Keith Jarvi of the Lunenfeld-Tanenbaum Research Institute, Mount Sinai Hospital in Toronto, Canada, said the holy grail of his research was to find a way to help men avoid unnecessary testicular biopsies.
He told BBC News: "The benefit of this is that we can predict without surgery whether or not a man has sperm or does not have sperm in the testicles.
"You could avoid unnecessary surgery for a number of these men."
He said work was under way to adapt the test for use in fertility clinics.
"Optimistically, it would be a year away," he added. "Pessimistically, two years - we're moving along really quickly."
Dr Allan Pacey, senior lecturer in andrology at the University of Sheffield and chairman of the British Fertility Society, said the diagnosis of male infertility was tricky and it was hard to determine whether a man was producing sperm or not.
The conventional method was to first examine semen under a microscope to see if sperm was there, he said.
If no sperm was seen, the next step was to take tissue from a man's testicle and examine it with a microscope.
"Quite understandably, many men would rather not undergo this procedure if they didn't have to," said Dr Pacey.
"Therefore, having an accurate biochemical test which might help doctors advise men whether taking a piece of the testicle is worth doing or not, would be very useful.
"It could help men make better decisions, avoid unnecessary surgical procedures and potentially help save money by not having to do surgical procedures that aren't needed.
"The fact that two protein markers present in semen can be so well correlated with whether sperm are likely to be found is very encouraging indeed."