Do witnesses in criminal cases have to testify in court?

Legal subjectivity:

Witnesses in criminal cases do not have to testify in court, and anyone who knows the circumstances of the case has the obligation to testify. However, both the prosecution and the defense and witnesses who are deemed unnecessary in the trial may not appear in court. A witness who applies to the people's court after being notified by a defense lawyer may decide whether to appear in court or not, and the spouse, parents and children of the criminal defendant may refuse to appear in court.

Legal objectivity:

Article 59 of the Criminal Procedure Law In the process of investigating the legality of evidence collection by the court, the people's procuratorate shall prove the legality of evidence collection. If the existing evidence materials cannot prove the legality of evidence collection, the people's procuratorate may request the people's court to notify the relevant investigators or other personnel to appear in court to explain the situation; The people's court may notify the relevant investigators or other personnel to appear in court to explain the situation. Relevant investigators or other personnel may also request to appear in court to explain the situation. Upon notification by the people's court, the relevant personnel shall appear in court. Article 62 Anyone who knows the circumstances of a case has the obligation to testify. A person who is physically and mentally defective or young, can't distinguish right from wrong and can't express correctly, can't be a witness.