function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Daniel BleasdaleDaniel Bleasdale 

Programme Area causing problems in my testing again!

Im always having problems with the "Programme Area" object. It never seems to want to test and Its always at this point I get stuck.
User-added imageUser-added imageUser-added image
Can somone help me with what im missing and tell me how you knew what I needed and where I needed it thankyou.
If it helps the "Programme Area" is a master Detail.

Thanks Dan
Best Answer chosen by Daniel Bleasdale
cvuyyurucvuyyuru
Just exchange lines 18 and 19 in your test class.
First insert programme area and then assign it's Id. You are doing viceversa.
Next time please paste your code rather than screenshots:)

All Answers

cvuyyurucvuyyuru
Just exchange lines 18 and 19 in your test class.
First insert programme area and then assign it's Id. You are doing viceversa.
Next time please paste your code rather than screenshots:)
This was selected as the best answer
Daniel BleasdaleDaniel Bleasdale
Thankyou but im still getting the same error.
@istest Private Static void ApprenticeObjTest(){
        
       Apprentice__c ApprenticeObj = new Apprentice__c();
       Programme_Area__c ProgramArea = new Programme_Area__c();
       ProgramArea.PA_Code__c = '112';
       ApprenticeObj.Date_of_Birth__c = date.parse('12/08/2000');
       System.assertEquals(ApprenticeObj, ApprenticeObj);
       insert ApprenticeObj;
       insert ProgramArea;
       ApprenticeObj.Programme_area__c = ProgramArea.Id;
User-added image
 
cvuyyurucvuyyuru
@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;
    }

Check this