You need to sign in to do that
Don't have an account?

Error When Preforming Validation On My Apex Class
When I go to Validate to set live I get this problem, It dosnt show in the testing and It dosnt cause any issues in the sandbox. I was wondering if anyone could help me solve it?
Controller:-
public class PrintableView { public final Apprentice__c App; public PrintableView(ApexPages.StandardController stdController) { this.App = (Apprentice__c)stdController.getRecord(); } public Apprentice__c ApprenticeObj{get;set;} public Programme_Area__c ProgramArea {get;set;} public Boolean bolPrintableView {get;set;} public void init() { String strPrintableView = ApexPages.currentPage().getParameters().get('print'); bolPrintableView = (strPrintableView == '1'); Programme_Area__c ProgramArea = new Programme_Area__c(); ProgramArea.PA_Code__c = '112'; insert ProgramArea; } public PrintableView(){ ApprenticeObj = new Apprentice__c(); ProgramArea = new Programme_Area__c(); } }Test Class:-
@isTest private class PrintViewTest { private Apprentice__c ApprenticeObj {get;set;} private Boolean bolPrintableView {get;set;} public PrintableView Pview {get;set;} public Programme_Area__c ProgramArea {get;set;} @istest Private Static void ApprenticeObjTest(){ Programme_Area__c ProgramArea = new Programme_Area__c(); ProgramArea.PA_Code__c = '112'; insert ProgramArea; Apprentice__c ApprenticeObj = new Apprentice__c(); ApprenticeObj.Date_of_Birth__c = date.parse('12/08/2000'); ApprenticeObj.Programme_area__c = ProgramArea.Id; insert ApprenticeObj; } @istest Private Static void StandardTest(){ Apprentice__c ApprenticeObj = new Apprentice__c(); Apexpages.StandardController sc = new Apexpages.standardController(ApprenticeObj); PrintableView PrintExt = new PrintableView(sc); } @istest Private Static void GetSetTest(){ PrintableView Pview = new PrintableView(); Pview.init(); // check that an Apprentice__c was created List<Apprentice__c> ApprenticeObj = [SELECT Id FROM Apprentice__c]; List<Programme_Area__c> ProgramArea = [SELECT Id FROM Programme_Area__c]; } }
Thanks for any help
All Answers
I'm not sure why you need the test method "apprenticeObjTest()", as it doesn't cover any of the controller. Does it test a trigger?