Here is an example of how to test a trigger. The trigger updates the stage on an opportunity when a task is created called 'Request New Media Plan'.
public class TestTrigger {
public static testmethod void task_aft_ins() { Opportunity opp = new Opportunity(currencyisocode = 'USD', Name= 'Big Sale in US', AccountID = '00120000004pkJlAAI', Type = 'Upsell', CloseDate = System.today(), Presentation_Date__c = System.today(), StageName = 'Presentation Stage'); insert opp; Task tsk = new Task(subject = 'Request New Media Plan', ActivityDate = System.today(), WhatID = opp.ID); insert tsk;
// Check that the trigger properly set the StageName to Proposal Stage Opportunity retOpp = [select StageName from Opportunity where id=:opp.id]; System.assertEquals('Proposal Stage', retOpp.StageName); }
Here is an example of how to test a trigger. The trigger updates the stage on an opportunity when a task is created called 'Request New Media Plan'.
public class TestTrigger {
public static testmethod void task_aft_ins() {
Opportunity opp = new Opportunity(currencyisocode = 'USD', Name= 'Big Sale in US', AccountID = '00120000004pkJlAAI', Type = 'Upsell', CloseDate = System.today(), Presentation_Date__c = System.today(), StageName = 'Presentation Stage');
insert opp;
Task tsk = new Task(subject = 'Request New Media Plan', ActivityDate = System.today(), WhatID = opp.ID);
insert tsk;
// Check that the trigger properly set the StageName to Proposal Stage
Opportunity retOpp = [select StageName from Opportunity where id=:opp.id];
System.assertEquals('Proposal Stage', retOpp.StageName);
}
}
Message Edited by MarioKorf on 04-17-2008 11:33 AM