how often does the letter "e" occur in:
q: why my test class is not entering 'for loop'? this is my trigger for finding duplicate for phone and mobilephone
trigger duplicate_mobile on contact (before insert, before update) {

      map<string,contact> mapcontact = new map<string,contact>();

      for(contact cont :trigger.new){
        if((cont.phone != null ) && (system.trigger.isinsert) ||(cont.phone != system.trigger.oldmap.get(cont.id).phone)){

            mapcontact.put(cont.phone,cont);
                         }
        if((cont.mobilephone!= null) && (system.trigger.isinsert) ||(cont.mobilephone!= system.trigger.oldmap.get(cont.id).mobilephone)){

          mapcontact.put(cont.mobilephone,cont); 
      }

     }

     for(contact cont :[select phone from contact where phone in:mapcontact.keyset()]){

         contact cc =  mapcontact.get(cont.phone);
         cc.phone.adderror('error');                                              
         }

         for(contact con :[select mobilephone from contact where mobilephone in:mapcontact.keyset()]){
            contact ccc = mapcontact.get(con.mobilephone);
            ccc.mobilephone.adderror('error already no is saved');
         }
     }

this is my unit test
@istest
//test methos for duplicate_mobile for contact
private class test_duplicate_mobile{
static testmethod void dup_phone(){
contact contw = new contact ();
    contw.lastname = 'tester';
    contw.phone = '9999999999';
    contw.mobilephone = '8888888888';
    insert contw;

    contact contr = new contact();
    contr.lastname='as';
    contr.phone = '7777777777';
    contr.mobilephone='0000000000';
    insert contr;

    contw.phone = '11111111111';
    contw.mobilephone = '8888888887';
    update contw;
}
}

i am getting 66% code coverage because it is not entering for loops
 this is snapshot of code coverage 


a: you're not entering the loop because the queries don't return any records. as far as i can tell, the purpose is to detect duplicate phone numbers, but you're not inserting duplicate phone numbers in your test.
try adding this to your test:
contact contr = new contact();
contr.lastname='as';
contr.phone = '9999999999';
contr.mobilephone='8888888888';
insert contr;


user
I counted one hundred and fifty "e"s in that text.
assistant