The word “testify” is first recorded in English in the late 14th century as testifie, having come from Late Latin testificare "to bear witness, proclaim". That word was formed from testi(s) "witness" and ficus "making". Testis comes from the Indo-European root trei- "three", with the sense of a "third person standing by (as a witness)".
There is a popular notion which suggests that Latin testis "witness" is related to testis "testicle", by the idea that a testicle "bears witness" of virility. This has not been proven, and some believe that testis "testicle" is actually related to Latin testa "pot, shell".
That connection has also given rise to the belief that the word testimony derives from the Roman practice of requiring a person who was swearing to tell the truth to hold his testicles in his right hand. This had the effect of excluding women and eunuchs from being witnesses. Etymologists differ on whether this is fact or fable, but it is interesting to note Genesis 24:1-3 (King James version):
24And Abraham was old, and well stricken in age: and the Lord had blessed Abraham in all things. 2 And Abraham said unto his eldest servant of his house, that ruled over all that he had, Put, I pray thee, thy hand under my thigh: 3 And I will make thee swear by the Lord, the God of heaven, and the God of the earth, that thou shalt not take a wife unto my son of the daughters of the Canaanites, among whom I dwell.