Yes, paternity tests can be done by court order. The reason this is so is because of custody battles, and the father wants to be sure the child is his before he either fights for the custody or pays for child support.
Prenatal DNA Paternity Testing.
In states like Kansas, in order to have the right to challenge a child being put up for adoption, soon after being born, the potential father must begin paying Child...
A mother can go to court and request an order for a paternity test. The court will issue the order and the named father will need to submit to a paternity test.