Good day please kindly assist me with my test class, I have no idea what I am missing but I am constantly getting the System.DmlException: Insert Failed: REQUIRED_FIELD_MISSING, Required fields are missing: [ParentId]:[ParentId]
Find below the test class, thanks for the help:
@isTest (seeAllData=true)
public class CIFController_test
{
static testMethod void CIFControllerTest()
{
test.startTest();
Lead newLead= new Lead
(
lastname = 'TestCase',
company = 'BrianCp',
Business_Declaration_Date__c = date.today(),
CEO__c = 'TestCase',
CFO__c = 'TestCase',
HCC__c = 'TestCase',
CEO_Date__c = date.today(),
CFO_Date__c = date.today(),
HCC_Date__c = date.today(),
Registered_Name__c = 'TestCase',
Date_Of_Registration__c = date.today(),
Customer_Name__c = 'TestCase',
Business_Profile__c = 'TestCase',
Telecommunications_Licences_if_any__c = 'TestCase',
Surname_and_First_Name__c = 'TestCase',
Job_Title__c = 'TestCase',
Telephone_Number__c = 'TestCase',
Email__c = '[email protected]',
Trading_As__c = 'TestCase',
VAT_Number__c = 'TestCase',
Registration_Number__c = 'TestCase',
Registered_Address__c = 'TestCase',
Business_Address__c = 'TestCase',
Billing_Contact_Telephone_Number__c = 'TestCase',
Postal_Address__c = 'TestCase',
Billing_Address_if_not_same_as_above__c = 'TestCase',
Billing_Contact_Surname_Name__c = 'TestCase',
Website__c = 'http://www.test.case',
Billing_Contact_Email_Address__c = '[email protected]',
Name_and_Address_of_Auditors__c = 'TestCase',
Bank__c = 'TestCase',
Branch_Name_and_Number__c = 'TestCase',
Account_Name__c = 'TestCase',
Account_Number__c = 'TestCase',
Account_Type__c = 'TestCase',
Name_of_Authorised_Bank_Signatory__c = 'TestCase',
Street_Name_Number__c = 'TestCase',
Building_Name__c ='TestCase',
Floor_and_Room_Number__c = 'TestCase',
Suburb__c = 'TestCase',
City_Postal_Code__c = 'TestCase',
Contact_Name__c = 'TestCase',
Contact_Fixed_Telephone_Number__c = 'TestCase',
Contact_Mobile_Number__c = 'TestCase',
Contact_Email__c = '[email protected]',
If_answered_Yes_for_such_payment__c = 'TestCase',
Name__c = 'TestCase',
Designation__c = 'TestCase',
A_Government_Official__c = true,
An_Official_of_an_International_Org__c = true,
A_Member_of_Political_Party__c = true,
A_Candidate_for_Gvt_Office__c = true,
Representative_Employee_of_any_above__c = true,
A_Relative_of_Any_Above__c= true,
Improper_Payment_Within_Past_5_yrs__c = true,
Company__c= true,
If_answered_Yes_to_any_of_the_above__c = 'TestCase',
Partnership__c= true,
Trust__c= true,
Non_Profit_Association__c= true,
Other__c= true,
dat__c = date.today()
);
insert newLead;
Attachment attach = new Attachment();
attach.Name='Unit Test Attachment';
Blob bodyBlob=Blob.valueOf('Unit Test Attachment Body');
attach.body=bodyBlob;
attach.parentId=newLead.id;
insert attach;
List<Attachment> attachments=[select id, name from Attachment where parent.id=:newLead.id];
System.assertEquals(1, attachments.size());
test.stopTest();
}
}