Do you remember the story of David and Bathsheba? David was the King of Israel at the time. One day, from his palace roof, he saw Bathsheba taking her bath, and from that moment on he wanted her. What he wanted he took. Of course, the inevitable happened, she fell pregnant. To hide his adultery he brought her husband, Uriah, back from the battlefield so that the conception would be seen as his. The only trouble was that Uriah took a vow of abstinence while he was home on leave. David then took the next step and had Uriah placed in the frontline of battle. He even had the troops withdraw to leave him stranded. Adultery had led to murder.
Some time later, Nathan the prophet exposed David. In the face of his sin David admitted his guilt and sought God's forgiveness. All those around him probably felt it smelt a bit, but in truth, David's standing in the sight of God remained secure, even though he was a murderer.
John the apostle, in his first letter, writes, "We know that we have come to know Jesus if we obey his commands." This thought gets repeated quite a bit in the letter. For example, "We know that we have passed from death to life, because we love our brothers." The point is simple enough, we can test whether we are a child of God, a "Christian", a "born-again believer", "saved". John seems to be saying that we can test whether we are one of Jesus' friends if we do the things he wants us to do.
The problem with this idea is that no one does what God wants them to do? David certainly didn't. Most of us literally break 8 of the Ten Commandments, some of us 9. David was a 10, but was still God's friend. Mind you, if we are an 8 we need to remember that we are murderers and adulterers in spirit. So do we past the test, and what about David?
The test is probably more about orientation than obedience. If my life is oriented toward doing what God wants then this is an evidence that I am in a relationship with Him which will extend into eternity. I may slip, even a big slip like David, but the orientation is what matters. On the other hand, if I am habitually acting against the Lord, such is an evidence that I don't really know Him.