You need to sign in to do that
Don't have an account?
Daniel Bleasdale
Apex Testing REQUIRED_FIELD_MISSING
When I go to set my Apex class to the live production and validate it this error shows :-
Here is my Apex Code which is used as a controller (Underlined is in red after testing) :-
Thanks
Here is my Apex Code which is used as a controller (Underlined is in red after testing) :-
public class myController{ public Apprentice__c ApprenticeObj{get;set;} public Apprenticeship_Component__c ComponentsObj{get;set;} public myController(){ ApprenticeObj = new Apprentice__c(); ComponentsObj = new Apprenticeship_Component__c(); } public void saveObjects(){ insert ApprenticeObj; ComponentsObj.Apprentice__c = ApprenticeObj.Id; insert ComponentsObj; } }Here is the Apex Testing code:-
@isTest private class ApexTesting { static testMethod void myUnitTest() { myController myC = new myController(); myC.saveObjects(); // check that an Apprentice__c was created List<Apprentice__c> ApprenticeObjs = [SELECT Id FROM Apprentice__c]; System.assert(ApprenticeObjs.size() > 0); } }Whats required to allow me to upload to the live production. Is it somthing im missing in my test class? and how do I implement it?
Thanks
Programme_Area__c is the required field on object Apprentice__c . so while inserting you have to give some value. Thanks,
Yogesh
All Answers
Programme_Area__c is the required field on object Apprentice__c . so while inserting you have to give some value. Thanks,
Yogesh
Ive applied this to my controller but the coverage is now 70 pecent.
Do you know what I can add to my Apex Testing to increase my coverage to reach the 75% requirement thankyou?
Cool..!!Try this code..
Just check and let me know if you got any problem.
Thanks,
Yogesh
If I put the Code at the bottom I get the same results.
Before calling the method in test class you have to insert two dummy record of Apprentice__c and Apprenticeship_Component__c
Copy this code as it is....In your code you put these lines after calling method.
Please let me know if still you got any problem.
Thanks,
Yogesh
Is this bit in the wrong place, no matter where I put it more errors apear -
The Code of test class you mention in first image is correct only.
But you have to remove that <b> from your code. after that you will not get any error.
Line 7 and Line 13 remove that <b> and </b>
Thanks,
Yogesh