After his triumph over Goliath, David becomes friends with Jonathan, the son of King Saul. Saul gets increasingly jealous of David and eventually David comes to believe that Saul will try to kill him.
So David and Jonathan make a solemn pledge to each other, they will test Saul and if Saul is, in fact angry at David, Jonathan will let him know. They pledge to protect each other.
So they put their test in place, and Saul is after David. Jonathan lets David know that - they part as friends and David goes into hiding to escape from Saul