However, an argument could be made that the scene is too contrived to be real. The whole town is out in the forest on the one night that Goodman Brown decides to travel through it? The pink ribbons he has just seen on his wife just happen to be laying in sight? There are many elements of this "journey" that are coincidental and mystical to suggest that it is a dream. In which case, one could fault the protagonist for having such serious doubts about his neighbors. You could also fault him for placing people too high on a pedastal, expecting them to always be pious and true. If Goodman Brown were to accept that to be human is to sin and repent, then he might not have turned his back so drastically on society, and might in turn have been able to lead and happier and fuller life.
I don't know that there is a definitive answer. Personally, I like to the think that it was not a dream. I like this interpretation because it helps reveal the dual nature of humanity. We are not strictly good, as Brown certainly thinks he is as he leaves Faith behind. We all have the potential for evil in our natures. I like how this is revealed to Brown by the devil. Not only does he learn that his lineage is not so saintly as he would like to think, but he also realizes that his peers are not as pious as he would like to believe. However, Brown appears to ultimately pass the very test he set out to in the beginning. He does not seem to abandon his faith, for at the very moment when he and Faith are about to take communion into the black mass, he tells her not to give in and to look heavenward. It is at this moment that he passes the test; he proves his faith, though it has been severely shaken.
This is a personal opinion type of question. It is never conclusively stated in the story whether it was a dream or a reality. The outcome is tragic, Young Goodman Brown lives the rest of his life a bitter, angry man who turns his back on his religion, his wife, and his community. Even to his dying day he is never able to forgive.
My students seem to come to the conclusion that it was to vivid to just be a dream. They look at the details and decide that the devil would further torture Brown in never letting him no the truth of the matter.