There is a passage in boook of Matthew where Jesus says, "You will recognize them by their fruits," and "I never knew you; depart from me, you workers of lawlessness." (See Matthew 7:15-23)
In the past, I'd associated these verses with salvation. They never really made sense to me as I understood salvation to simply be this: putting trust in the completed work of Jesus on the cross. There was no external test of a person's salvation and one could not really examine another's faith. So what was Jesus talking about when he said, "You will recognize them by their fruits?"
I realized the key to understanding this was in the phrase: "Beware of false prophets". In this passage, Jesus was addressing the question of how we would differentiate a true prophet versus a false one. Outwardly, these false prophets come in "sheep's clothing". They are indistinguishable in their conduct. But the profession and teaching that came from their mouths will expose them. Their fruit is their word.
There is a parallel in Matthew 12:33-37 where Jesus talks about out of the abundance of the heart, the mouth speaks. Our words—our fruit—reveal what's in our hearts. So, these false prophets in Matthew 7:15-23 were relying on their works to be saved (wonders, prophesy and the casting out demons). They never professed trust in Jesus for their salvation; instead, they relied on their works. They even tried to be intimate with Jesus, calling him "Lord, Lord". The doubling of the word implies intimacy but what does Jesus say to them? "I never knew you; depart from me."
Therefore, in these verses, we find a group of people doing great things in Jesus' name, but they never did put their trust in Jesus as their Saviour. They used his name, but they never trusted him for their salvation. And that's the context of this passage: identifying a false prophet by what he says. It is not a passage about identifying a true believer.