If the test is on a subject that I thoroughly understand, it'd go no stress.
If the party is in the evening (10pm and onwards) I wouldn't go because I need to be well rested for studying the following day.
If the study work is too hard and the party means a lot to the person. I'd make an appearance at the party, stay for 30-45 minutes then go study. as long as the person knows that you cared enough to come, they'll be cool with it.