title: How to improve the coverage of this test class in Apex?
body: <p>I have created a test class with 51% code coverage till line no 34.</p>
  
  <p>Further, I tried to satisfy if condition but I couldn't. Now I am not getting how to do with 100% code coverage.</p>
  
  <p>Here is the Apex class:</p>
  
  <pre><code>public class AssignProjectController {
  public String CaseIds;
  public String status {get;set;}
  public List&lt;Project__c&gt; activeProjects {get;set;}
  public String keyWordSearched {get;set;}
  public Id projectId {get;set;}
  public AssignProjectController (){       
      CaseIds = ApexPages.currentPage().getParameters().get('id');             
  }
  
  public void getProjects(){
   status  = '';
    String searchQuery = 'FIND \'' + keyWordSearched + '*\' IN ALL FIELDS RETURNING Project__c (id,Name,Description__c where Status__c =\'Active\')';
    try{
    List&lt;List&lt;Project__c &gt;&gt; searchList = search.query(searchQuery); 
    activeProjects  = searchList[0];
    if(activeProjects.size() == 0) status = 'No search result found.';
    }catch(Exception ex){
      system.debug('ex..'+ex.getMessage());
      }}}
  public PageReference assignProjectToCases(){ 
      List&lt;Case__c&gt; customSettingList = Case__c.getall().values();
      List&lt;String&gt; settingRecordTypeList = new List&lt;String&gt;();         
      for(Case__c caseObj:customSettingList){
          settingRecordTypeList.add(caseObj.Name);
      }   
     List&lt;RecordType&gt; recordTypeListData = [SELECT Id FROM RecordType WHERE SObjectType = 'Case' and Name In : settingRecordTypeList];        
      if(CaseIds != null){
          List&lt;String&gt; caseIDList = new List&lt;String&gt;(); 
          caseIDList = CaseIds.split(',');                        
          if([Select id from Case where Id In : caseIDList and RecordType.Id NOT In : recordTypeListData].size() &gt; 0){
             status  = 'failed';
          }else{
               List&lt;Case&gt; cases = [Select id,Project__c,RecordType.Name from Case where Id In : caseIDList and RecordType.Id In : recordTypeListData];
               if(cases.size() &gt; 0){
                  for(case caseOb: cases){            
                      caseOb.Project__c = projectId ;
                  }        
                  try{
                      update cases ;
                      status  = 'Changes are scheduled';
                   }catch(Exception ex){
                      system.debug('AssignProjectController :::'+ex.getMessage());
                      status  = 'Something Went Wrong';
                  }}}}
       return null;
   }}
  </code></pre>
  
  <p>Here is the test class- which I tried to resolve</p>
  
  <pre><code> @isTest public class TestAssignProjectController {
  public static Project__c insertProject(){
      Project__c proObj = new Project__c();
      proObj.Name = 'testProject';
      proObj.Status__c = 'Active';
      proObj.Description__c = 'for testing';
      proObj.Internal_Email_Alias__c = 'a@test.com';
      return proObj;
  }
  public static Account getAccount(){
      Account accoObj = new Account();
      accoObj.Name  = 'testAcc';
      accoObj.Location__c = 'testLocation';
      accoObj.Type = 'CM';
      accoObj.BillingCountry = 'United States';
      return accoObj;
  }
  public static Contact insertContact(Account accObj){
      Contact conObj = new Contact();
      conObj.FirstName = 'test';
      conObj.LastName = 'testLastname';
      conObj.AccountId = accObj.Id;
      conObj.Email = 'abc@gmail.com';
      return conObj;
  }
   public static Id getTechTypeId(){
      return Schema.SObjectType.Case.getRecordTypeInfosByName().get('Tech ').getRecordTypeId();
  }
  public static Case insertCase(String conId, String proId){
      Case caseObj = new Case();
      caseObj.Project__c = proId;
      caseObj.ContactId = conId;
      caseObj.Status = 'Open';
      caseObj.Inquiry_Type__c = 'All'; 
      caseObj.Subject = 'TestSubject';
      caseObj.Description = 'TestDescription';
      caseObj.Case_Is_Reopened__c = false;
      caseObj.RecordTypeId = getTechTypeId();
      return caseObj;
  }
  public static testmethod void testMethodExecution(){
      AssignController asigncon = new AssignController ();
  
      Project__c proObj = insertProject();
      insert proObj;
      System.assertEquals(proObj.Status__c,'Active');
      Account accObj = getAccount();
     insert accObj;
     System.assertNotEquals(accObj.Id,null);
      Contact conObj = insertContact(accObj);
     insert conObj;
     System.assertNotEquals(conObj.Id,null);
     Case caseObj = insertCase(conObj.Id, proObj.Id);
     insert caseObj; 
     system.debug(caseObj);  
    //Set baseURL &amp; case ID
      PageReference pageRef = Page.Assign;
      pageRef.getParameters().put('id',caseObj.id+',');
      AssignController asigncon1 = new AssignController ();
      asigncon1.getProjects();
      asigncon1.assignProjectToCases();
  }}
  </code></pre>