+ Start a Discussion

How to create a Test Apex Class?


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);
 return send;



Thank you for your help,
In fact, I have tried by didn't succeed:
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');