+ Start a Discussion
YASSINE1YASSINE1 

How to create a Test Apex Class?

Hello,

I need help for creating an apex test class for a standard controller method:

public with sharing class New_Personnel_Action_controller {

public ID getNewId = System.currentPagereference().getParameters().get('newid');
public Flow.Interview.PAF_New_Personnel_Action myflow{get;set;}
public New_Personnel_Action_controller (ApexPages.StandardController stdController) {
        getNewId = ApexPages.currentPage().getParameters().get('recordId');
    }

public String getTheNewId(){ return getNewId; }
public ID returnId = getNewId;

public PageReference getNewRecord(){

 if(myflow != null) returnId = myflow.ID_new_record;

 PageReference send = new PageReference('/' + returnId);
 send.setRedirect(true);
 return send;

}

}

Thank you for your help,
Yassine
YASSINE1YASSINE1
In fact, I have tried by didn't succeed:
@isTest
private class New_Personnel_Action_controller_Test {

    @isTest static void getNewRecordtest() {
        ApexPages.StandardController sc=new ApexPages.StandardController();
        
        New_Personnel_Action_controller NPAC=new New_Personnel_Action_controller(sc);
        
            System.assertNotEquals(null, NPAC.getNewRecord(),'test');
    }
}