When a woman becomes pregnant and the embryo implants into the lining of the uterus, the trophoblast cells give off a hormone called human chorionic gonadotrophin (hCG). In standard pregnancy tests, hCG is detected and causes a reaction, resulting in a positive or negative result.
The same trophoblast cells also exist in malignant cancer (specifically uterine and testicular cancer) and function the same as they do in early pregnancy. Because the trophoblast cells produce the hCG hormone, pregnancy tests are able to detect the presence of cancer.
A man, obviously bored, recently took a pregnancy test as a prank. When the results came back positive, he joked about it on Reddit. Reddit users responded by telling him to get to an oncologist. The man ended up having a tumor on his testicle, and while he will lose the testicle, in reality, the pregnancy test saved his life.