• TestUtil
  • 0 Points
  • Member since 2008

  • Chatter
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
  • 2
Hey all,

I've read these boards for a while and noticed a decent amount of gripes regarding testing your Force.com applications with the testing framework provided in Apex.

I have this ever growing test utility class that I use to aid in my Apex testing, and I was thinking putting it up on the AppExchange (for free of course :P ) but I wanted it to address as many of your problems and pain points as possible.

What I'm looking for are any helper methods you use and find helpful in your own testmethod writing. Also, if you have any pain points with testing in general, please list them and I can see if I can't think of some util to make the effort a little easier for you.

Any feedback welcome!

Hi All,

I apologize if my question has been asked many times. Please point me to the right article. Thanks.

I have an opportunity trigger that accepts or rejects changes (close date) based on today's date. I need to know how to temporarily set the today's date to a particular date while testing the trigger, similar to System.RunAs() method that allows me to execute codes under a certain user's profile, except this is to "pretend" the codes are executed on a particular date?. Can someone show me the trick?


I've got the following trigger which simply puts the Account.OwnerId in as the Contact.OwnerId before insert.  When I convert a lead, the trigger doesn't work -- but only in Production.  When I do this in a Development instance, it does work. 
Why would this be?  It is the only "before insert" trigger that I have on Contact.  The only other trigger I have is a "before update" one.  I've got no triggers on Lead.  I find it very strange!!


trigger contactInsertOwner on Contact (before insert) {

Set<Id> accSet = new Set<Id>();

     for ( Contact newContact : Trigger.new )




Map<Id, Account> accMap = new Map<Id, Account>([select Id, OwnerId

                                   from Account where Id in :accSet]);

        for ( Contact updContact : Trigger.new )


              updContact.OwnerId = accMap.get(updContact.AccountId).OwnerId;