0
我是一個完整的代碼noob,需要幫助編寫Salesforce中觸發器的測試類。任何幫助將不勝感激。在Salesforce中的觸發器上編寫測試類
這裏是觸發:
trigger UpdateWonAccounts on Opportunity(before Update) {
Set <Id> accountIds = new Set <Id>();
//Collect End user Ids which has won Opportunities
for (Opportunity o : Trigger.new) {
if (o.isWon && o.EndUserAccountName__c != null) {
accountIds.add(o.EndUserAccountName__c);
}
}
List <Account> lstAccount = new List <Account>();
//Iterate and collect all the end user records
for (Account a : [Select Id, Status__c From Account where Id IN : accountIds]) {
lstAccount.add(new Account(Id = a.Id, Status__c = true));
}
//If there are any accounts then update the records
if (!lstAccount.isEmpty()) {
update lstAccount;
}
}
你需要編寫代碼來測試這個特定的觸發幫助嗎?或者你一般需要幫助創建單元測試課程? – slashingweapon