The Ad hominem fallacy occurs when the arguer presents an argument and the opponent instead of attacking the argument attacks the arguer. Hence it is a fallacy of irrelevance because the opponent's response is irrelevant to deciding if the argument is good or bad.
Giving an openly insult towards the arguer ("your stupid so your argument is false")is the most common but not the only form of ad hominem . Another form is veiled insults such "your not knowledgeable on this matter" , "not mature enough" , " not old enough" . All these responses EVEN if they were true would not undermine the argument ON THERE OWN.
Another very important form of ad hominem is called "ad hominem circumstantial", where the opponent asserts that since the arguer has a stake in the conclusion therefore his argument is false. for example suppose a filthy rich person presents an argument for why the tax rates should be reduced. In response the opponent says "well of course he wants taxes to be lowered thats because he want to save his enormous wealth from excessive taxation hence his argument is false" . this response EVEN if true would be fallacious on its own.
In my view the most ideal discussion would be one where there are no persons at all only beliefs and the respective arguments and evidence interacting with each other. but since beliefs , arguments etc are ideas and ideas can exist only inside persons therefore the presence of a person in the discussion is a necessary evil . but thats the only role the person plays : to anchor the ideas . nothing more.
Notice the contrast where in ordinary discussion or those we see on the television we almost always start with an attack on the opponent ("your biased/liar/brainwashed"...) i myself have engaged in this fallacy so many times. it comes so naturally to us and for that reason one needs to be EXTRA careful.
PS : case for testimonial evidence is different. ad hominems can be justified sometimes in that matter.