You need to sign in to do that
Don't have an account?
Nitzan Marinov
Trying to deploy a Validation Rule
Hi,
I'm trying to deploy a validation rule and I get a Code Ceverage Failure. The vaildation is against the Current_Address__c field in the custome object Clients and the rule is:
AND (ISBLANK( Current_Address__c ), OR(ISNEW(),ISCHANGED(Current_Address__c)))
I have made sure that all the client records with a blank address were updated with a value ('N/A') and I still get the error messages on deployment validation.
Component Errors
, Details: Average test coverage across all Apex Classes and Triggers is 70%, at least 75% test coverage is required.
AttendeeControllerTEST.testAddClientToAllSessions(); AttendeeControllerTEST.testAddClientToSession(), Details: System.DmlException: Insert failed. First exception on row 0; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, Please enter a valid Current Address for the client: [Current_Address__c] Class.AttendeeControllerTEST.testAddClientToAllSessions: line 30, column 1; System.DmlException: Insert failed. First exception on row 0; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, Please enter a valid Current Address for the client: [Current_Address__c] Class.AttendeeControllerTEST.testAddClientToSession: line 10, column 1
TESTCLASS_EventTrigger.validateEventTrigger(), Details: System.DmlException: Insert failed. First exception on row 0; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, Please enter a valid Current Address for the client: [Current_Address__c] Class.TESTCLASS_EventTrigger.validateEventTrigger: line 11, column 1
Apex Test Failures
AttendeeControllerTEST testAddClientToSession System.DmlException: Insert failed. First exception on row 0; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, Please enter a valid Current Address for the client: [Current_Address__c]
Stack Trace: Class.AttendeeControllerTEST.testAddClientToSession: line 10, column 1
AttendeeControllerTEST testAddClientToAllSessions System.DmlException: Insert failed. First exception on row 0; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, Please enter a valid Current Address for the client: [Current_Address__c]
Stack Trace: Class.AttendeeControllerTEST.testAddClientToAllSessions: line 30, column 1
TESTCLASS_EventTrigger validateEventTrigger System.DmlException: Insert failed. First exception on row 0; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, Please enter a valid Current Address for the client: [Current_Address__c]
Stack Trace: Class.TESTCLASS_EventTrigger.validateEventTrigger: line 11, column 1
Thanks for your help.
I'm trying to deploy a validation rule and I get a Code Ceverage Failure. The vaildation is against the Current_Address__c field in the custome object Clients and the rule is:
AND (ISBLANK( Current_Address__c ), OR(ISNEW(),ISCHANGED(Current_Address__c)))
I have made sure that all the client records with a blank address were updated with a value ('N/A') and I still get the error messages on deployment validation.
Component Errors
, Details: Average test coverage across all Apex Classes and Triggers is 70%, at least 75% test coverage is required.
AttendeeControllerTEST.testAddClientToAllSessions(); AttendeeControllerTEST.testAddClientToSession(), Details: System.DmlException: Insert failed. First exception on row 0; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, Please enter a valid Current Address for the client: [Current_Address__c] Class.AttendeeControllerTEST.testAddClientToAllSessions: line 30, column 1; System.DmlException: Insert failed. First exception on row 0; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, Please enter a valid Current Address for the client: [Current_Address__c] Class.AttendeeControllerTEST.testAddClientToSession: line 10, column 1
TESTCLASS_EventTrigger.validateEventTrigger(), Details: System.DmlException: Insert failed. First exception on row 0; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, Please enter a valid Current Address for the client: [Current_Address__c] Class.TESTCLASS_EventTrigger.validateEventTrigger: line 11, column 1
Apex Test Failures
AttendeeControllerTEST testAddClientToSession System.DmlException: Insert failed. First exception on row 0; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, Please enter a valid Current Address for the client: [Current_Address__c]
Stack Trace: Class.AttendeeControllerTEST.testAddClientToSession: line 10, column 1
AttendeeControllerTEST testAddClientToAllSessions System.DmlException: Insert failed. First exception on row 0; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, Please enter a valid Current Address for the client: [Current_Address__c]
Stack Trace: Class.AttendeeControllerTEST.testAddClientToAllSessions: line 30, column 1
TESTCLASS_EventTrigger validateEventTrigger System.DmlException: Insert failed. First exception on row 0; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, Please enter a valid Current Address for the client: [Current_Address__c]
Stack Trace: Class.TESTCLASS_EventTrigger.validateEventTrigger: line 11, column 1
Thanks for your help.
You have corrected the data in the system.
However, you have test classes where you are creating some data and the validation is failing for such records.
AttendeeControllerTEST.testAddClientToAllSessions(); AttendeeControllerTEST.testAddClientToSession(), Details: System.DmlException: Insert failed. First exception on row 0; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, Please enter a valid Current Address for the client: [Current_Address__c] Class.AttendeeControllerTEST.testAddClientToAllSessions: line 30, column 1; System.DmlException: Insert failed. First exception on row 0; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, Please enter a valid Current Address for the client: [Current_Address__c] Class.AttendeeControllerTEST.testAddClientToSession: line 10, column 1
TESTCLASS_EventTrigger.validateEventTrigger(), Details: System.DmlException: Insert failed. First exception on row 0; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, Please enter a valid Current Address for the client: [Current_Address__c] Class.TESTCLASS_EventTrigger.validateEventTrigger: line 11, column 1
In the above errors, you need to go to the class 'AttendeeControllerTEST'. Check this method 'testAddClientToAllSessions()'. In this method, on line 30 you're creating a client record without current_Address__c. Hence you are getting the failures.
Similarly, correct this in all test classes wherever you're creating client data.
Hope this helps you :)
I'm new to this so need some more help...
I'm looking at the code of this Apex Class and don't understand where I can find the insertClinet function to change it.
/**
*/
@isTest
private class AttendeeControllerTEST {
static testMethod void testAddClientToSession() {
Clients__c c = TestUtilities.insertClient();
insert c;
Project__c p = TestUtilities.insertProject();
insert p;
Event e = new Event(Subject='Test',ActivityDateTime=datetime.now(),WhatId=p.Id,DurationInMinutes=10);
insert e;
Test.setCurrentPageReference(Page.EventAttendees);
AttendeeController con = new AttendeeController();
apexPages.currentPage().getParameters().put('EventID', e.Id);
system.assert(con.ClientList.size()==1);
con.clientList[0].isSelected = true;
con.SaveAttendees();
}
static testMethod void testAddClientToAllSessions() {
Clients__c c = TestUtilities.insertClient();
insert c;
Project__c p = TestUtilities.insertProject();
insert p;
Event e = new Event(Subject='Test',ActivityDateTime=datetime.now(),WhatId=p.Id,DurationInMinutes=10);
insert e;
Test.setCurrentPageReference(Page.EventAttendees);
AttendeeController con = new AttendeeController();
apexPages.currentPage().getParameters().put('ProjectId', p.Id);
system.assert(con.ClientList.size()==1);
con.clientList[0].isSelected = true;
con.SaveAttendees();
}
}
Could you please look and tell em where to find the next step?
Thanks
Nitzan
Sorry for the delay. Was on holiday today.
You need to go to this class 'TestUtilities'. That's where we have this method 'insertClient()' which creates Client records.
Thanks for showing me where to look :-)
I'll let you know if I have any more questions.