0

I am only starting to learn coding. 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 from sandbox. I tried all the existing test classes available in production, because I don't know how to create a test class. Below is the code for my controller, please check if there's something wrong with it:

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;
}
}
0

1 Answer 1

0

There's nothing wrong with your code, though it could be optimized:

public class MyController {
  ApexPages.StandardController sc;
  public MyController(ApexPages.StandardController sc) {
    this.sc = sc;
  }
  public void quicksave() {
    sc.save();
  }
}

As far as covering it with a unit test, you can read this question.