There is a type of DNA testing that can be performed while the mother is still pregnant to identify if the person is a father of the conceived fetus. There are regular schedules to be followed for such a test and you need not worry about it because it's one that is safe for the mother and the baby.
The reason why DNA testing can be done even before the child is born is because it's there already during conception. A child gets to have an equal half share of the mother and the father's blood and genes. That is why a person becomes unique. The unique creation of children from a combination of genes and blood makes all kids in the family unique too. Your brothers and sisters can be easily identified through the DNA test by the doctors. The only case where DNA paternity test results are the same is if your children are twins.
There are cases when a court order is released and requests that a child has to undergo DNA testing, and this case needs to follow certain procedures required by law. The mother as well as the father should be facing the officials while the samples are being swabbed from them. Both the samples will be brought to the laboratory for proper testing and analysis. On the other hand, if parents wants to make sure of the child's DNA but without a court order, the doctor can take samples from each of them and then they can perform it at home.
As the child is 10 to 13 weeks yet of gestation, the doctor can be asked to get samples from the baby and conduct DNA testing which is known as the non-invasive testing. This should be done at that stage because the doctor needs to get a good amount of sample from the child's placenta.
Another type is the amnio DNA testing where the mother would have to reach 14 up to 20 weeks of pregnancy. Extraction of the sample fluid which comes from the surrounding of the infant will be done through a large needle that would have to be inserted in the womb of the mother. What is not risky for the infant in the womb though is the carrying out of non-invasive testing. In amnio testing, the doctor just have to make sure that the needle is inserted properly. For older women conceiving a child, the doctors usually make sure if the child is having down syndrome through amnio DNA testing. Parents can also request for such even if the doctor has not given a suggestion so they can be ready in case it's true.
Now you see how technology has made these DNA testing possible. Depending on one's needs, there are several different types of DNA tests to choose from.