I have a trigger that i have written that I need tested to be able to get code coverage in salesforce:
here is the trigger:
Trigger MyCh_SALESFORCETRIGGERUPDATE_tr_I on Account (after insert)
{
set<ID> ids = Trigger.newMap.keyset();
for(ID id : ids)
{
MyCh_Account__c change = new MyCh_Account__c();
change.Action__c = 'insert';
change.Link__c = id;
change.Processed__c = false;
change.Map__c = 'SALESFORCE TRIGGER UPDATE';
insert change;
}
}
I have tried :
@isTest
public class MyAccountcreationTest
{
static testMethod void testMethod1()
{
Account testAccount = new Account();
testAccount.Name='Test Account' ;
insert testAccount;
Account acc1 = [Select Id, Link__c, Action__c, Processed__c, Map__c from Account where Id =: testAccount.Id];
System.assertEquals(acc1.Name,'Test Account');
System.assertEquals(acc1.Link__c, acc1.Id);
System.assertEquals(acc1.Processed__c,false);
System.assertEquals(acc1.Map__c,'SALESFORCE TRIGGER UPDATE');
System.assertEquals(acc1.Action__c,'insert');
}
}
I expect the test to pass but it gives an error : Map__c , Action__c , Link__c are not fields of Account object.
Also , how does the test actually link to the trigger itself ?