function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Andrew Fisher 28Andrew Fisher 28 

Test Class code coverage-Help!

Hi I can only get 66% coverage for this apex class, could someone kindly help me get above 75% please?

Apex Class
public class OpptyCloseTimerCntrl {
    
    @AuraEnabled
    public static Date fetchOpptyCloseDate(String recId){
        Opportunity opp = [select End_of_Quarter__c from Opportunity where id =: recId];
        system.debug('Close Date: ' +opp.End_of_Quarter__c);
        
        return opp.End_of_Quarter__c;
    }
}

test class I have:
@isTest
private class OpptyCloseTimerCntrl_Test{
  @testSetup
  static void setupTestData(){
    test.startTest();
    Opportunity opportunity_Obj = new Opportunity(IsPrivate = false, Name = 'Name749', StageName = '1. Selection', CloseDate = Date.today(), X1_MIFIS_Pipeline__c = false, X2_VDF_Persona__c = false, X3_VDF_Workshop_Doc__c = false, X4_ICETEA__c = false, X5_Forecast__c = false, Named_Account__c = false, Strategic__c = false, DVM_Volume_Sale__c = false, DSCORGPKG__Converted_from_Discoverorg_Data__c = false, Exclusion__c = false, Acronis_Referral__c = false, Existing_ARR__c = false, REVGRD__CreatedBySCC__c = false, Professional_Services_Project__c = false, Future_Q__c = false, Cloud_Strategy_Populated__c = false, Company_Vision_Strategy_Populated__c = false, Competition_Populated__c = false, Custom_Dev__c = false, Decision_Makers_Populated__c = false, Decision_Making_Criteria_Populated__c = false, Decision_Making_Process_Populated__c = false, MDF__c = false, Non_Standard_Billing_Terms__c = false, Non_Standard_Discount__c = false, Non_Standard_Pricing_Terms__c = false, Non_Standard_Taxation_Terms__c = false, Optimal_Future_State_Populated__c = false, Organizational_Pain_Impact_Populated__c = false, Pain_We_Address_Populated__c = false, Payment_Terms_60_Days__c = false, Scope_of_Work__c = false, Solution_Needs_Populated__c = false, Specific_Invoice_Terms__c = false, Technical_Description_Populated__c = false, MQL_Lead_Origin__c = false, X2021_MQL__c = false, LID__Is_Influenced__c = false, Confirm_Customer_Support_Set_up_Complete__c = false, Production_VHI_License_Provided__c = false, MQL_exclude__c = false, Customer_needs_KA_access__c = false, Customer_needs_KA_hierarchy__c = false, Do_not_send_onboarding_email__c = false, Is_SO_Signed_agreement_attached__c = false, customer_needs_community_accounts__c = false, Contact_Role_Added__c = false);
    Insert opportunity_Obj; 
    test.stopTest();
  }
  static testMethod void test_fetchOpptyCloseDate_UseCase1(){
    List<Opportunity> opportunity_Obj  =  [SELECT End_of_Quarter__c from Opportunity];
    System.assertEquals(true,opportunity_Obj.size()>0);
    OpptyCloseTimerCntrl obj01 = new OpptyCloseTimerCntrl();
    OpptyCloseTimerCntrl.fetchOpptyCloseDate('test data');
  }
}

Any help would be highly appreciated