function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
DaGunsterDaGunster 

PLEASE - Point me somewhere where there is a hard example of TESTING TRIGGERS

Please. I got to get my trigger out into production.
GerhardNewman2GerhardNewman2

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);
        }

}

 
 
 
MarioKorfMarioKorf
Are we really getting emoticons in our code? Test: where id=opp.id vs where id= opp.id  =0 =o =O



Message Edited by MarioKorf on 04-17-2008 11:33 AM