If you are in foreclosure in a judicial foreclosure state, your case can "go to trial."
Some homeowners think they want to go to trial to have their day in court, a chance to tell their story to a judge or jury and get justice. However, real life is not like an episode of a legal drama show. There will be no sensational surprise at the end, and probably not much of anything exciting. And even if you do win, you will not get a free house.
In many cases, it makes sense to avoid going to trial because it's better to come to an agreement with the lender before it gets to that point. But sometimes that's not practical, and a case does end up at trial.