forked from deepikakhanna/SalesforcePlatformDeveloper1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tutorial46TestClassExample
22 lines (18 loc) · 944 Bytes
/
tutorial46TestClassExample
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
@isTest
private class CustomerTriggerTestClass {
static testMethod void myUnitTest() {
//Create Data for Customer Objet
APEX_Customer__c objCust = new APEX_Customer__c();
objCust.Name = 'Test Customer';
objCust.APEX_Customer_Status__c = 'Inactive';
insert objCust;
//Now, our trigger will fire on After update event so update the Records
Test.startTest();//Starts the scope of test
objCust.APEX_Customer_Status__c = 'Active';
update objCust;
Test.stopTest();//Ends the scope of test
//Now check if it is giving desired results using system.assert Statement.New invoice should be created
List<apex_invoice__c> invList = [SELECT Id, APEX_Customer__c FROM APEX_Invoice__c WHERE APEX_Customer__c = :objCust.id];
system.assertEquals(1,invList.size());//Check if one record is created in Invoivce sObject
}
}