Since Contact
is parent for Customer_Address__c
Object, there might be case that one Contact
can have multiple Customer_Address__c
Object.
So replace this line:
Customer_Address__c customerAddress=[SELECT ID,Customer__c,Customer_Address_ID__c FROM Customer_Address__c WHERE Customer__c =:contact.Id ];
With:
List<Customer_Address__c> customerAddressList=[SELECT ID,Customer__c,Customer_Address_ID__c FROM Customer_Address__c WHERE Customer__c =:contact.Id ];
Also in your test class you're not creating customer_address__c
data. That's why you're getting that error. Add below lines after inserting contact
in your test class:
Customer_Address__c customer = new Customer_Address__c ();
customer.Customer__c = contact.id;
customer.Customer_Address_ID__c = 'customer Id';
insert customer;