The law contains a number of exceptions as to when a person may be compelled by a Court to testify. Common examples include when the attorney-client privilege applies or when the 5th amendment privilege against self-incrimination applies. Attorneys cannot be compelled to testify as to the subject matter of their legal communications with a client or former client. An individual, moreover, cannot be forced to testify as to anything which has a reasonable likelihood of resulting in criminal liability. While there are exceptions to these privileges, these are the general rules.
Another such privilege is the marital communications privilege. A spouse who is called to testify may permissibly refuse to testify if the information elicited relates to communications with his/her spouse. Note that the privilege rests solely with the testifying spouse. The non-testifying spouse cannot prevent the testifying spouse from giving testimony.
As with the initial privilege articulated, this privilege is not unlimited. It generally goes away in cases of divorce/dissolution of marriage. The privilege does not apply with respect to civil proceeding in which the spouses are adverse parties. It does not apply in any criminal proceeding in which an un-refuted showing is made that the spouses acted jointly in the commission of a crime.