A paternity test is conducted to prove that a man is or is not the biological father of another individual. This may be relevant in view of rights and duties of the father. Similarly, a maternity test can be carried out. This is less common, because at least during childbirth, it is obvious who the mother is.
This can best be achieved by DNA analysis of the three individuals, although older methods have included ABO blood group typing, analysis of various other proteins and enzymes, or using HLA antigens. For the most part however, DNA has all but taken over all the other forms of testing.
The DNA of an individual is almost exactly the same in each and every somatic cell. Sexual reproduction brings the DNA of both parents together randomly to create a unique combination of genetic material in a new cell, so the genetic material of an individual is derived from the genetic material of their parents. This genetic material is known as the nuclear genome of the individual, because it is found in the nucleus.
Comparing the DNA sequence of an individual to that of another individual can show if one of them was derived from the other or not. Specific sequences are usually looked at to see if they were copied verbatim from one of the individuals genome to the other. If that was the case, then this proves that the genetic material of one individual was derived from that of the other (i.e.: one is the parent of the other). This way, paternity can be proved or disproved.
Besides the nuclear DNA in the nucleus, the mitochondria in the cells also have their own genetic material termed the mitochondrial genome. Mitochondrial DNA comes only from the mother, without any shuffling.
Proving a relationship based on comparison of the mitochondrial genome is much easier than that based on the nuclear genome. However, testing the mitochondrial genome can only prove if two individuals are related by common descent through maternal lines only from a common ancestor and is thus of limited value (for instance, it could not be used to test for paternity).
Obtaining news that a child either is or isn't one's own is someting that a parent or erstwhile (?) parent can undertake at their own expense, without necessarily informing anyone either about the test or its result. Tests can also be ordered by courts when proof of paternity is required. It is accepted that a father's permission should be sought for a paternity test in any circumstance. It is always better to know.