@isTest
private class Test_ordinefermo {
@isTest
static void test_newAttachment(){
test.startTest();
Opportunity op= new Opportunity();
op.Name= 'abc';
op.StageName='Open';
op.Trattativa__c = 'Automotive';
op.CloseDate = date.valueOf('2017-11-12');
op.Tipo_di_Trattativa__c = 'Cross Selling';
insert op;
file_ordine_fermo__c fofc = new file_ordine_fermo__c();
fofc.Name = 'fofcdemo';
fofc.Trattativa_Correlata__c =op.Id;
insert fofc;
ApexPages.StandardController std = new ApexPages.StandardController(fofc);
ordinefermo ord= new ordinefermo(std);
ord.newAttachment();
test.stopTest();
}
}
I have above test class testing a extention ordinefermo
. when I try to test newAttachment()
method is giving me
System.DmlException: Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [Trattativa_Correlata__c]: [Trattativa_Correlata__c]
But I have already populated Trattativa_Correlata__c
field in my test class.
When I try to deleting the statement ord.newAttachment();
the test case is being successful but I am falling behind code coverage as I am not testing the method.
Trattativa_Correlata__c
field. Can you highlight line, where this exception occurs ?