Why didnt he testify in court?
Because he is famous the world over for blatantly lying, and that works great at his rallies, but in court it damns him.
He hired very clever, very expensive lawyers - not fools - and they knew that if they had any chance of preventing him from being condemned by his sin, the last thing they want him to do in a court of law is open his mouth.