Competency to Testify
At common law atheists, children, the mentally impaired, convicted felons, accomplices, parties, parties' spouses and other interested persons were considered incompetent to testify because these witnesses could either 1) not be trusted to respect the oath or 2) had an interest in the proceedings. Today most of these witnesses can testify, subject to some limitations.
As a general rule, most witnesses are presumed to be competent and able to give testimony at a trial. However, competency may be tested for each individual witness. In the U.S. Federal Courts, competency is determined on a case-by-case basis.
General requirements for competency:
- Oath or Affirmation - In many courts every witness shall be required to declare that the witness will testify truthfully, by oath or affirmation administered in a form calculated to awaken the witness' conscience and impress the witness' mind with the duty to do so. If the individual does not understand the oath or affirmation, then they may be incompetent to testify.
- Knowledge - A witness is only competent to testify if they have personal knowledge of the facts to which they will testify. 
Competency to testify merely acts as a gatekeeper function keeping certain unreliable witness out of court. That is to say, a competent witness is not automatically reliable or material. A trier of fact (judge or jury) may still discount the testimony as weightless.
If there is a question of mental disability, it is the duty of the opposing counsel to raise the issue of the competency of the adult. If one party raises the question of a witness's competency to testify, the court may order a hearing. So there is a voir dire usually held (this stands for the competence of both children and mentally ill), during which:
- The witness must answer questions as to their ability to tell the truth.
- The witness is asked whether he or she understands what an oath or affirmation is.
- The witness is examined to determine whether he or she understands the duty to speak the truth in terms of everyday social conduct.
At the end of the hearing, the judge will determine whether the witness is competent to testify. Since this is a question of law rather than a question of fact, the judge, rather than the jury, will decide it. This is usually a discretionary decision for trial judges as they can see all aspects of the testimony. The burden of proof is on the opposing party to prove incompetence.
The rules for children are similar to those for the mentally disabled. In most jurisdictions, children under a particular age are presumed to be incompetent to testify. For instance, in Canada a child is presumed to be incompetent if they are under the age of 14.
In some jurisdictions, when the child is presumed incompetent, the party offering the witness must announce to the court that this child is under the age of competence and a similar voir dire as the one for mentally disabled is held.
If a child is presumed to be incompetent under local evidence law, the lawyer may still attempt to prove competency by overcoming:
- The concern that children are easily influenced.
- The presumption that a child cannot understand the moral obligation to tell the truth.
It is also possible to argue that the goal is to ensure the evidence meets the minimum threshold of being receivable rather than to decide whether the evidence is credible.
Even if the evidence is admissible, the trier of fact does not have to give the evidence much weight.
Depending on the jurisdiction, spouses may be incompetent to testify against one another in a criminal case. In the U.S. Federal Courts this common law rule was abolished with the advent of the Federal Rules of Procedure. However, some states retain a version of the spousal incompetence rule. For instance, in New York one spouse may be incompetent to testify against another spouse if the issue is adultery. Spouses are not compellable witnesses.
Spouses may also be barred from testifying because of the the marital confidences privilege or the spousal testimonial privilege. Note the difference between incompetence and privilege: spouses may be incompetent to testify (because of bias) but the relationship is privileged so the information exchanged is not admissible (to protect the sanctity of marriage). Technically, communications prior to marriage would not be covered by the marital privilege, but in the case of criminal offenses spouses are not competent, so you cannot get them in the box.
Admissions are considered an exception to the hearsay rule. If a child overhears a direct admission (e.g. mother telling father), this is still an admission. So long as they are hearing it from the principle's mouth, whether or not they are the direct recipient is inconsequential.
Because of the inherent conflict of interest, a judge should not be allowed to testify as to facts in a trial over which she is presiding. 
A juror should not be allowed to testify as to the facts in a trial over which he is a trier of fact. However, in certain circumstances, a juror may be called to testify as to whether extraneous prejudicial information was improperly brought to the jury's attention, whether any outside influence was improperly brought to bear upon any juror, or whether there was a mistake in entering the verdict onto the verdict form. 
Dead Man's Statute
Certain jurisdictions may have enacted so-called "Dead Man's Statutes" which prevent certain parties from testifying as to business dealings with deceased individuals.
No testimony is allowed in civil cases for the party opposing a dead or incompetent person, by parties, interested persons or predecessors, about or dealing with the dead or incompetent person unless the dead or incompetent person opens the door to inclusion of the evidence or unless the testimony is about the facts of an accident in a negligence case.
"Upon the trial of an action . . . a party or a person interested in the event . . . shall not be examined as a witness in his own behalf or interest . . . concerning a personal transaction or communication between the witness and the deceased person . . . except where the executor . . . is examined in his own behalf . . . concerning the same transaction or communication." 
- Federal Rules of Evidence - Rule 603. Oath or Affirmation
- Federal Rules of Evidence - Rule 602. Lack of Personal Knowledge
- New York Civil Practice Law and Rules 4502
- Federal Rules of Evidence - Rule 605. Competency of Judge as Witness
- Federal Rules of Evidence - Rule 606. Competency of Juror as Witness
- New York Civil Practice Law and Rules 4519(a)