You need to sign in to do that
Don't have an account?
Trif Cristian 7
How to write a System.assert() for this test method?
static void testUpdate() {
User userStandard = TestUtil.getUserStandardDE(0);
System.runAs(userStandard) {
Account accountBusiness= [Select Id from Account where Name = :TestUtil.ACCOUNT_BUSINESS_NAME LIMIT 1];
Account accountBusinessDuplicate= [Select Id from Account where Name = 'DuplicateCompany' LIMIT 1];
AccountDuplicate__c ad = new AccountDuplicate__c();
ad.Account1__c = accountBusiness.Id;
ad.Account2__c = accountBusinessDuplicate.Id;
ad.Status__c = 'Open';
ad.Criteria__c ='Other matches';
Test.startTest();
insert ad;
ad.Remarks__c = 'changed';
update ad;
ad.Status__c = 'Rejected';
update ad;
ad.Status__c = 'Open';
update ad;
Test.stopTest();
}
}
User userStandard = TestUtil.getUserStandardDE(0);
System.runAs(userStandard) {
Account accountBusiness= [Select Id from Account where Name = :TestUtil.ACCOUNT_BUSINESS_NAME LIMIT 1];
Account accountBusinessDuplicate= [Select Id from Account where Name = 'DuplicateCompany' LIMIT 1];
AccountDuplicate__c ad = new AccountDuplicate__c();
ad.Account1__c = accountBusiness.Id;
ad.Account2__c = accountBusinessDuplicate.Id;
ad.Status__c = 'Open';
ad.Criteria__c ='Other matches';
Test.startTest();
insert ad;
ad.Remarks__c = 'changed';
update ad;
ad.Status__c = 'Rejected';
update ad;
ad.Status__c = 'Open';
update ad;
Test.stopTest();
}
}
Please check once below sample code.
More Info : https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_methods_system_system.htm
Hope this helps you!
Thanks
Varaprasad
@For Support: varaprasad4sfdc@gmail.com
All Answers
A simple scenario would be to create a test class +methods in which some work is done (e.g. put something into the DB, update a field or whatever). Once this is done you would use System.Assert functions to check what has been done.
For example:-
integer i = 0;
integer j = 1;
//this would throw an error and cause your test to fail
System.assertEquals(i,j);
//this would pass
System.assertNotEquals(1,i);
you could interchange any of the Assert functions dependent on your logic. Up to you. I find it easier to use AssertEquals as I mostly want to check that a proper number of records have been returned or that something I know about has happened and I'm expecting a certain result etc...
Thanks
Vinod
Please check once below sample code.
More Info : https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_methods_system_system.htm
Hope this helps you!
Thanks
Varaprasad
@For Support: varaprasad4sfdc@gmail.com