You need to sign in to do that
Don't have an account?
Érick BS
SetupClassTest - TriggerClass Validation
Hi! I am new with SF Apex programming, then I am stuck with a simple problem I think so.
After I added a Validation Rule to unable the user saves a new account without entering data in the fields (ShippingCity, ShippingPostalCode, ShippingStreet) I am facing some problems with a trigger test class.
I must be able to put fake values in my trigger test for these new fields that now are required field.
Could you help me, pls?
After I added a Validation Rule to unable the user saves a new account without entering data in the fields (ShippingCity, ShippingPostalCode, ShippingStreet) I am facing some problems with a trigger test class.
I must be able to put fake values in my trigger test for these new fields that now are required field.
Could you help me, pls?
@isTest static void UpdateAccountProspect1() { Boolean result = true; try{ User testUser = SetupClassTest.createUserSalesRep('2801','testadmin@testorg.com', 'testadmin@testorg.com.prod'); System.runAs(testUser){ RecordTypeInfo rt = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('Prospect_2801'); List<Account> accToUpdate = SetupClassTest.generateNAccountsWithRT(1, rt.getRecordTypeId(), '2801'); accToUpdate[0].RecordTypeId = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('Customer_2801').getRecordTypeId(); update accToUpdate[0]; } }catch(Exception e){ System.debug('Línea: ' + e.getStackTraceString()); result = false; } System.assert(result); }
You can find one more apex class named SetupClassTest in your org. In that class find the method generateNAccountsWithRT there you can add the new values for Account.
If you have any confusion please post the code here.
Thanks,
Maharajan.C
All Answers
You can find one more apex class named SetupClassTest in your org. In that class find the method generateNAccountsWithRT there you can add the new values for Account.
If you have any confusion please post the code here.
Thanks,
Maharajan.C
First of all, thank you for you help!
I will share with you my code... I can´t use this method... I tried the follow code, but I receive an error "Class.AccountTriggerHandlerTest.UpdateAccountAsSystemAdmin: line 243, column 1"
This was so obvious that I did not see this when I look at for the first time!
But now I can add new values always as I want to.
Thanks very much!