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
RichardR1RichardR1 

help create test class please

Hello, I am just learning development but I need to be able to use my custom controller I created for use in a visualforce page in production. I can't get past code coverage failure when I try to deploy. Not sure if there's something wrong with my custom controller. I tried all the existing test classes available in production. Below is the code for my controller:
public class MyController {

public ApexPages.StandardController sc;

public MyController(ApexPages.StandardController sc) {
    this.sc = sc;
}

public void quicksave() {
    AVTRRT__Job_Applicant__c j = (AVTRRT__Job_Applicant__c) sc.getRecord();
    update j.AVTRRT__Contact_Candidate__r;
}
}

 
Best Answer chosen by RichardR1
RichardR1RichardR1
this is solved because a developer helped me create a proper test class. Thanks

All Answers

AnudeepAnudeep (Salesforce Developers) 
You can use the following code to get started
 
@istest()
public class testMyController
{
      private static testmethod void testMyControllerTestsMethod()
     {

    //insert the object here
     AVTRRT_JobApplicant__c obj = new AVTRRT_JobApplicant__c(Name ='Test');
     insert obj;
 
     ApexPages.StandardController sc = new ApexPages.StandardController(obj);
     MyController testController = new MyController(sc);

         }
     }

NOTE: The code provided is an example. You'll need to review and make modifications for your organization.
RichardR1RichardR1
this is solved because a developer helped me create a proper test class. Thanks
This was selected as the best answer