A person who timely offers a defense of insanity in accordance with the Rules of Criminal Procedure may be found guilty but mentally ill at trial. Under this rule, the defendant must have some mental condition that prevented them from resisting the urge or impulse to commit the alleged offense.In Pennsylvania, insanity is a defense and the test to determine it is referred to as the M'Naughten Test. Insanity pleas in Pennsylvania can be confusing. It's important to know the difference in determining insanity and mental illness. To reach our office, call 215-343-3055, or fill out the form on our contact page. The insanity defense is only available to those defendants who come within the purview of Pennsylvania's legal test for insanity. (b) Plea of guilty but mentally ill. --A person who waives his right to trial may plead guilty but mentally ill. 234 Pa. Code Rule 568.