0
我在Salesforce APEX中記錄了觸發器。它工作正常。爲Salesforce/APEX觸發器編寫測試類
代碼爲觸發器是:
trigger SDRDemoUpdate_test on Event (before update) {
Map<ID,Event> records = New Map<ID,Event>([SELECT CreatedBy.Name FROM Event WHERE ID IN: trigger.new]);
for (Event obj :Trigger.new){
obj.SDR_Original_Demo__c = records.get(obj.id).CreatedBy.Name;
}
}
現在我嘗試寫代碼的測試類。它在線發出錯誤,表示對象不能被解析爲字符串。
代碼爲測試類:
@isTest
public class originalDemo {
static testMethod void test_original_demo() {
Event obj = new Event();
obj.CreatedBy = 'Tom';
obj.Owner = 'Jack';
obj.What = 'Opportunity';
insert.obj;
userInfo.getName();
}
}
期待找出解決方案。任何幫助,將不勝感激。
感謝