One family noticed their barley was sprouting, while another's didn't. Shortly after, the family with the sprouts had a baby. It could have taken generations for this to be actually used as a pregnancy test.
Women generally have a good idea, perhaps some women started to observe it as they maybe didn't want more children and didn't want men to know about it and we worried about each and every possible indication that could reveal it.
Urine was (and is) considered to be strong magically tied to the person, so it was on focus for shamans and priests since ages. And used in combination with many other materials, to heal, to foresee, to curse ..
And given, that urine does contain many personal informations, there is truth to it ..