trigger OpportunityTrigger on Opportunity (before insert) {
for(Opportunity thisOpportunity : Trigger.New) {
thisOpportunity.New_Value__c ='Actual Trigger Value';
}
}
This is my test class
@isTest private class OpportunityTriggerHandler_Test {
@isTest static void test_OpportunityTriggerHandler() {
Contact ordwayContact = New Contact();
ordwayContact.LastName = 'abjsb';
ordwayContact.MailingStreet = 'Indore';
insert ordwayContact;
Test.startTest();
Opportunity testOpportunity = new Opportunity(
StageName = 'Prospecting',
CloseDate = system.today(),
BillingContact__c = ordwayContact.Id,
Name = 'Test Opportunity Triggers'
);
insert testOpportunity;
system.debug('ordwayOpportunity'+testOpportunity.New_Value__c);
Test.stopTest();
}
I am not getting the thisOpportunity.New_Value__c in my test class. When I insert the record through UI I am avail to see this value but when I do this through test class not getting the value in the test class