1

all. I'm new to Apex and writing my first trigger. I think it should work fine, but I'm stuck on my test class; I can't seem to get the necessary coverage level. Everything within the if(trigger.isUpdate) statement isn't covered, but I can't figure out why. Please help!

Here is my trigger class:

trigger LastEventDate on Event (after insert, after update) 
{
Set <Id> whatIdSet = new Set <Id> ();
for(Event e : trigger.new)
{
    if(e.WhatId != null)
    {
        whatIdSet.add(e.WhatId);
    }
}

// Creates two maps in case whatId is not populated
Map<ID, Account> accountMap = new Map<ID, Account>([select Id,  
                                                           Last_Review_Meeting__c, 
                                                           Last_FP_Update__c, 
                                                           Last_IPS_Update__c,  
                                                           Last_Tax_Planning_Meeting__c, 
                                                           Last_Tax_Prep_Meeting__c, 
                                                           Previous_Review_Meeting__c, 
                                                           Previous_FP_Update__c, 
                                                           Previous_IPS_Update__c,  
                                                           Previous_Tax_Planning_Meeting__c, 
                                                           Previous_Tax_Prep_Meeting__c 
                                                           from Account 
                                                           Where Id in :whatIdSet]);

List<Event> eventList = [select Id,  
                                WhatID, 
                                StartDateTime, 
                                FSTR__Sub_Type__c,  
                                Status__c, 
                                Financial_Plan_Update__c, 
                                IPS_Updated__c, 
                                Tax_Plan__c
                                from Event 
                                Where WhatId in :whatIdSet];


// The actual Accounts to save
List <Account> AccountsToUpdate = new List <Account> ();

for(Event e : Trigger.new)
{
/*  
if(Trigger.isUpdate)
{
    Event oldEvent = Trigger.oldMap.get(e.ID);
}
*/
    if(e.WhatID != null && accountMap.containsKey(e.whatId))
    {

        Account a1 = accountMap.get(e.WhatId);
        Date d1 = Date.newInstance(e.ActivityDateTime.year(), e.ActivityDateTime.month(), e.ActivityDateTime.day());

        //If new meeting is scheduled as planned, set this meeting date to the appropriate Last Meeting Date field

        if(e.Status__c != 'Canceled' && e.Status__c != 'Re-Scheduled' && Trigger.isInsert)
        {
                if(e.FSTR__Sub_Type__c == 'Tax Preparation Meeting')
                {
                    if(d1 > a1.Last_Tax_Prep_Meeting__c)
                    {
                        a1.Last_Tax_Prep_Meeting__c = d1;
                    }
                }

                if(e.FSTR__Sub_Type__c == 'Tax Planning Meeting' || e.Tax_Plan__c)
                {
                    if(d1 > a1.Last_Tax_Planning_Meeting__c)
                    {
                        a1.Last_Tax_Planning_Meeting__c = d1;
                    }
                }

                if(e.FSTR__Sub_Type__c == 'Client Review Meeting')
                {
                    if(d1 > a1.Last_Review_Meeting__c)
                    {
                        a1.Last_Review_Meeting__c  = d1;
                    }
                }

                if(e.Financial_Plan_Update__c)
                {
                    if(d1 > a1.Last_FP_Update__c)
                    {
                        a1.Last_FP_Update__c = d1;
                    }
                }

                if(e.IPS_Updated__c)
                {
                     if(d1 > a1.Last_IPS_Update__c)
                     {
                        a1.Last_IPS_Update__c = d1;
                     }
                }

                AccountsToUpdate.add (a1);
        }

        // If meeting is canceled or rescheduled, update all Last Meeting date fields

        if(Trigger.isUpdate)
        {
                a1.Last_Review_Meeting__c=null;
                a1.Last_FP_Update__c=null;
                a1.Last_IPS_Update__c=null;
                a1.Last_Tax_Planning_Meeting__c=null;
                a1.Last_Tax_Prep_Meeting__c=null;

                for(Integer i=0; i<=eventList.size()-1; i++)
                {
                    // Tax Planning Meeting
                    if(eventList[i].FSTR__Sub_Type__c == 'Tax Preparation Meeting' && eventList[i].WhatID == a1.Id && eventList[i].ActivityDateTime > a1.Last_Tax_Prep_Meeting__c && eventList[i].Status__c == 'Scheduled')
                    {
                        a1.Last_Tax_Prep_Meeting__c = Date.newInstance(eventList[i].ActivityDateTime.year(), eventList[i].ActivityDateTime.month(),eventList[i].ActivityDateTime.day());
                    }

                    // Tax Prep Meeting
                    if(eventList[i].FSTR__Sub_Type__c == 'Tax Planning Meeting' || eventList[i].Tax_Plan__c)
                    {
                       if(eventList[i].WhatID == a1.Id && eventList[i].ActivityDateTime > a1.Last_Tax_Planning_Meeting__c && eventList[i].Status__c == 'Scheduled')
                       {
                          a1.Last_Tax_Planning_Meeting__c = Date.newInstance(eventList[i].ActivityDateTime.year(), eventList[i].ActivityDateTime.month(),eventList[i].ActivityDateTime.day());
                       }
                    }

                    // Client Review Meeting
                    if(eventList[i].FSTR__Sub_Type__c == 'Client Review Meeting' && eventList[i].WhatID == a1.Id && eventList[i].ActivityDateTime > a1.Last_Review_Meeting__c && eventList[i].Status__c == 'Scheduled')
                    {
                        a1.Last_Review_Meeting__c = Date.newInstance(eventList[i].ActivityDateTime.year(), eventList[i].ActivityDateTime.month(),eventList[i].ActivityDateTime.day());
                    }

                    // IPS Update
                    if(eventList[i].IPS_Updated__c && eventList[i].WhatID == a1.Id && eventList[i].ActivityDateTime > a1.Last_IPS_Update__c && eventList[i].Status__c == 'Scheduled')
                    {
                        a1.Last_IPS_Update__c = Date.newInstance(eventList[i].ActivityDateTime.year(), eventList[i].ActivityDateTime.month(), eventList[i].ActivityDateTime.day());
                    }

                    // FP Update
                    if(eventList[i].Financial_Plan_Update__c && eventList[i].WhatID == a1.Id && eventList[i].ActivityDateTime > a1.Last_FP_Update__c && eventList[i].Status__c == 'Scheduled')
                    {
                        a1.Last_FP_Update__c = Date.newInstance(eventList[i].ActivityDateTime.year(), eventList[i].ActivityDateTime.month(),eventList[i].ActivityDateTime.day());
                    }
                }

                AccountsToUpdate.add (a1);

        }

        try
        {
            update AccountsToUpdate;
        }
        catch (System.DmlException ex)
        {
            System.Debug (ex);
        }
      }

    }
 }

And here is my test class:

@IsTest(SeeAllData=true)

public class TestLastMeetingUpdate 
{

static testmethod void insertEvent() 
{

    List<Account> accounts = new List<Account>();
    accounts.add(new Account(Name='Test Acct 1',
                             Last_Review_Meeting__c = date.newInstance(2015, 8, 1),
                             Last_Tax_Prep_Meeting__c = date.newInstance(2015, 8, 1),
                             Last_Tax_Planning_Meeting__c = date.newInstance(2015, 8, 1),
                             Last_FP_Update__c = date.newInstance(2015, 8, 1),
                             Last_IPS_Update__c = date.newInstance(2015, 8, 1),
                             Previous_Review_Meeting__c = date.newInstance(2014, 8, 1),
                             Previous_Tax_Prep_Meeting__c = date.newInstance(2014, 8, 1),
                             Previous_Tax_Planning_Meeting__c = date.newInstance(2014, 8, 1),
                             Previous_FP_Update__c = date.newInstance(2014, 8, 1),
                             Previous_IPS_Update__c = date.newInstance(2014, 8, 1)));
    accounts.add(new Account(Name='Test Acct 2',
                             Last_Review_Meeting__c = date.newInstance(2015, 8, 1),
                             Last_Tax_Prep_Meeting__c = date.newInstance(2015, 8, 1),
                             Last_Tax_Planning_Meeting__c = date.newInstance(2015, 8, 1),
                             Last_FP_Update__c = date.newInstance(2015, 8, 1),
                             Last_IPS_Update__c = date.newInstance(2015, 8, 1),
                             Previous_Review_Meeting__c = date.newInstance(2014, 8, 1),
                             Previous_Tax_Prep_Meeting__c = date.newInstance(2014, 8, 1),
                             Previous_Tax_Planning_Meeting__c = date.newInstance(2014, 8, 1),
                             Previous_FP_Update__c = date.newInstance(2014, 8, 1),
                             Previous_IPS_Update__c = date.newInstance(2014, 8, 1)));
    accounts.add(new Account(Name='Test Acct 3',
                             Last_Review_Meeting__c = date.newInstance(2015, 8, 1),
                             Last_Tax_Prep_Meeting__c = date.newInstance(2015, 8, 1),
                             Last_Tax_Planning_Meeting__c = date.newInstance(2015, 8, 1),
                             Last_FP_Update__c = date.newInstance(2015, 8, 1),
                             Last_IPS_Update__c = date.newInstance(2015, 8, 1),
                             Previous_Review_Meeting__c = date.newInstance(2014, 8, 1),
                             Previous_Tax_Prep_Meeting__c = date.newInstance(2014, 8, 1),
                             Previous_Tax_Planning_Meeting__c = date.newInstance(2014, 8, 1),
                             Previous_FP_Update__c = date.newInstance(2014, 8, 1),
                             Previous_IPS_Update__c = date.newInstance(2014, 8, 1)));
    accounts.add(new Account(Name='Test Acct 4',
                             Last_Review_Meeting__c = date.newInstance(2015, 8, 1),
                             Last_Tax_Prep_Meeting__c = date.newInstance(2015, 8, 1),
                             Last_Tax_Planning_Meeting__c = date.newInstance(2015, 8, 1),
                             Last_FP_Update__c = date.newInstance(2015, 8, 1),
                             Last_IPS_Update__c = date.newInstance(2015, 8, 1),
                             Previous_Review_Meeting__c = date.newInstance(2014, 8, 1),
                             Previous_Tax_Prep_Meeting__c = date.newInstance(2014, 8, 1),
                             Previous_Tax_Planning_Meeting__c = date.newInstance(2014, 8, 1),
                             Previous_FP_Update__c = date.newInstance(2014, 8, 1),
                             Previous_IPS_Update__c = date.newInstance(2014, 8, 1)));
    accounts.add(new Account(Name='Test Acct 5',
                             Last_Review_Meeting__c = date.newInstance(2015, 8, 1),
                             Last_Tax_Prep_Meeting__c = date.newInstance(2015, 8, 1),
                             Last_Tax_Planning_Meeting__c = date.newInstance(2015, 8, 1),
                             Last_FP_Update__c = date.newInstance(2015, 8, 1),
                             Last_IPS_Update__c = date.newInstance(2015, 8, 1),
                             Previous_Review_Meeting__c = date.newInstance(2014, 8, 1),
                             Previous_Tax_Prep_Meeting__c = date.newInstance(2014, 8, 1),
                             Previous_Tax_Planning_Meeting__c = date.newInstance(2014, 8, 1),
                             Previous_FP_Update__c = date.newInstance(2014, 8, 1),
                             Previous_IPS_Update__c = date.newInstance(2014, 8, 1)));
    accounts.add(new Account(Name='Test Acct 6',
                             Last_Review_Meeting__c = date.newInstance(2015, 8, 1),
                             Last_Tax_Prep_Meeting__c = date.newInstance(2015, 8, 1),
                             Last_Tax_Planning_Meeting__c = date.newInstance(2015, 8, 1),
                             Last_FP_Update__c = date.newInstance(2015, 8, 1),
                             Last_IPS_Update__c = date.newInstance(2015, 8, 1),
                             Previous_Review_Meeting__c = date.newInstance(2014, 8, 1),
                             Previous_Tax_Prep_Meeting__c = date.newInstance(2014, 8, 1),
                             Previous_Tax_Planning_Meeting__c = date.newInstance(2014, 8, 1),
                             Previous_FP_Update__c = date.newInstance(2014, 8, 1),
                             Previous_IPS_Update__c = date.newInstance(2014, 8, 1)));
    accounts.add(new Account(Name='Test Acct 7',
                             Last_Review_Meeting__c = date.newInstance(2015, 8, 1),
                             Last_Tax_Prep_Meeting__c = date.newInstance(2015, 8, 1),
                             Last_Tax_Planning_Meeting__c = date.newInstance(2015, 8, 1),
                             Last_FP_Update__c = date.newInstance(2015, 8, 1),
                             Last_IPS_Update__c = date.newInstance(2015, 8, 1),
                             Previous_Review_Meeting__c = date.newInstance(2014, 8, 1),
                             Previous_Tax_Prep_Meeting__c = date.newInstance(2014, 8, 1),
                             Previous_Tax_Planning_Meeting__c = date.newInstance(2014, 8, 1),
                             Previous_FP_Update__c = date.newInstance(2014, 8, 1),
                             Previous_IPS_Update__c = date.newInstance(2014, 8, 1)));
    accounts.add(new Account(Name='Test Acct 8',
                             Last_Review_Meeting__c = date.newInstance(2015, 8, 1),
                             Last_Tax_Prep_Meeting__c = date.newInstance(2015, 8, 1),
                             Last_Tax_Planning_Meeting__c = date.newInstance(2015, 8, 1),
                             Last_FP_Update__c = date.newInstance(2015, 8, 1),
                             Last_IPS_Update__c = date.newInstance(2015, 8, 1),
                             Previous_Review_Meeting__c = date.newInstance(2014, 8, 1),
                             Previous_Tax_Prep_Meeting__c = date.newInstance(2014, 8, 1),
                             Previous_Tax_Planning_Meeting__c = date.newInstance(2014, 8, 1),
                             Previous_FP_Update__c = date.newInstance(2014, 8, 1),
                             Previous_IPS_Update__c = date.newInstance(2014, 8, 1)));
    accounts.add(new Account(Name='Test Acct 9',
                             Last_Review_Meeting__c = date.newInstance(2015, 8, 1),
                             Last_Tax_Prep_Meeting__c = date.newInstance(2015, 8, 1),
                             Last_Tax_Planning_Meeting__c = date.newInstance(2015, 8, 1),
                             Last_FP_Update__c = date.newInstance(2015, 8, 1),
                             Last_IPS_Update__c = date.newInstance(2015, 8, 1),
                             Previous_Review_Meeting__c = date.newInstance(2014, 8, 1),
                             Previous_Tax_Prep_Meeting__c = date.newInstance(2014, 8, 1),
                             Previous_Tax_Planning_Meeting__c = date.newInstance(2014, 8, 1),
                             Previous_FP_Update__c = date.newInstance(2014, 8, 1),
                             Previous_IPS_Update__c = date.newInstance(2014, 8, 1)));
    accounts.add(new Account(Name='Test Acct 10',
                             Last_Review_Meeting__c = date.newInstance(2015, 8, 1),
                             Last_Tax_Prep_Meeting__c = date.newInstance(2015, 8, 1),
                             Last_Tax_Planning_Meeting__c = date.newInstance(2015, 8, 1),
                             Last_FP_Update__c = date.newInstance(2015, 8, 1),
                             Last_IPS_Update__c = date.newInstance(2015, 8, 1),
                             Previous_Review_Meeting__c = date.newInstance(2014, 8, 1),
                             Previous_Tax_Prep_Meeting__c = date.newInstance(2014, 8, 1),
                             Previous_Tax_Planning_Meeting__c = date.newInstance(2014, 8, 1),
                             Previous_FP_Update__c = date.newInstance(2014, 8, 1),
                             Previous_IPS_Update__c = date.newInstance(2014, 8, 1)));
    accounts.add(new Account(Name='Test Acct 11',
                             Last_Review_Meeting__c = date.newInstance(2015, 8, 1),
                             Last_Tax_Prep_Meeting__c = date.newInstance(2015, 8, 1),
                             Last_Tax_Planning_Meeting__c = date.newInstance(2015, 8, 1),
                             Last_FP_Update__c = date.newInstance(2015, 8, 1),
                             Last_IPS_Update__c = date.newInstance(2015, 8, 1),
                             Previous_Review_Meeting__c = date.newInstance(2014, 8, 1),
                             Previous_Tax_Prep_Meeting__c = date.newInstance(2014, 8, 1),
                             Previous_Tax_Planning_Meeting__c = date.newInstance(2014, 8, 1),
                             Previous_FP_Update__c = date.newInstance(2014, 8, 1),
                             Previous_IPS_Update__c = date.newInstance(2014, 8, 1)));
    accounts.add(new Account(Name='Test Acct 12',
                             Last_Review_Meeting__c = date.newInstance(2015, 8, 1),
                             Last_Tax_Prep_Meeting__c = date.newInstance(2015, 8, 1),
                             Last_Tax_Planning_Meeting__c = date.newInstance(2015, 8, 1),
                             Last_FP_Update__c = date.newInstance(2015, 8, 1),
                             Last_IPS_Update__c = date.newInstance(2015, 8, 1),
                             Previous_Review_Meeting__c = date.newInstance(2014, 8, 1),
                             Previous_Tax_Prep_Meeting__c = date.newInstance(2014, 8, 1),
                             Previous_Tax_Planning_Meeting__c = date.newInstance(2014, 8, 1),
                             Previous_FP_Update__c = date.newInstance(2014, 8, 1),
                             Previous_IPS_Update__c = date.newInstance(2014, 8, 1)));

    insert accounts;

    List<Event> events = new List<Event>();

    events.add(new Event(Subject = 'Review Meeting',
                         WhatID = accounts[0].Id,
                         ActivityDateTime = datetime.newInstance(2015, 8, 19, 10, 30, 0),
                         FSTR__SUB_TYPE__C = 'Client Review Meeting',
                         FINANCIAL_PLAN_UPDATE__C = TRUE,
                         TAX_PLAN__C = TRUE,
                         IPS_UPDATED__C = TRUE,
                         Status__c = 'Scheduled',
                         DurationInMinutes = 60));

    events.add(new Event(Subject = 'Tax Prep Meeting',
                         WhatID = accounts[1].Id,
                         ActivityDateTime = datetime.newInstance(2015, 8, 20, 11, 30, 0),
                         FSTR__SUB_TYPE__C = 'Tax Prep Meeting',
                         FINANCIAL_PLAN_UPDATE__C = TRUE,
                         TAX_PLAN__C = FALSE,
                         IPS_UPDATED__C = TRUE,
                         Status__c = 'Scheduled',
                         DurationInMinutes = 60));

    events.add(new Event(Subject = 'Tax Planning Meeting',
                         WhatID = accounts[2].Id,
                         ActivityDateTime = datetime.newInstance(2015, 8, 21, 12, 30, 0),
                         FSTR__SUB_TYPE__C = 'Tax Planning Meeting',
                         FINANCIAL_PLAN_UPDATE__C = TRUE,
                         TAX_PLAN__C = FALSE,
                         IPS_UPDATED__C = TRUE,
                         Status__c = 'Scheduled',
                         DurationInMinutes = 60));

    events.add(new Event(Subject = 'Review Meeting',
                         WhatID = accounts[3].Id,
                         ActivityDateTime = datetime.newInstance(2015, 8, 22, 13, 30, 0),
                         FSTR__SUB_TYPE__C = 'Client Review Meeting',
                         FINANCIAL_PLAN_UPDATE__C = TRUE,
                         TAX_PLAN__C = TRUE,
                         IPS_UPDATED__C = TRUE,
                         Status__c = 'Scheduled',
                         DurationInMinutes = 60));

     events.add(new Event(Subject = 'Tax Prep Meeting',
                         WhatID = accounts[4].Id,
                         ActivityDateTime = datetime.newInstance(2015, 8, 23, 14, 30, 0),
                         FSTR__SUB_TYPE__C = 'Tax Prep Meeting',
                         FINANCIAL_PLAN_UPDATE__C = FALSE,
                         TAX_PLAN__C = TRUE,
                         IPS_UPDATED__C = TRUE,
                         Status__c = 'Scheduled',
                         DurationInMinutes = 60));                            

    events.add(new Event(Subject = 'Tax Planning Meeting',
                         WhatID = accounts[5].Id,
                         ActivityDateTime = datetime.newInstance(2015, 8, 24, 15, 30, 0),
                         FSTR__SUB_TYPE__C = 'Tax Planning Meeting',
                         FINANCIAL_PLAN_UPDATE__C = TRUE,
                         TAX_PLAN__C = FALSE,
                         IPS_UPDATED__C = TRUE,
                         Status__c = 'Scheduled',
                         DurationInMinutes = 60));

    events.add(new Event(Subject = 'Review Meeting',
                         WhatID = accounts[6].Id,
                         ActivityDateTime = datetime.newInstance(2015, 8, 25, 10, 30, 0),
                         FSTR__SUB_TYPE__C = 'Client Review Meeting',
                         FINANCIAL_PLAN_UPDATE__C = TRUE,
                         TAX_PLAN__C = TRUE,
                         IPS_UPDATED__C = TRUE,
                         Status__c = 'Canceled',
                         DurationInMinutes = 60));

    events.add(new Event(Subject = 'Tax Prep Meeting',
                         WhatID = accounts[7].Id,
                         ActivityDateTime = datetime.newInstance(2015, 8, 26, 11, 30, 0),
                         FSTR__SUB_TYPE__C = 'Tax Prep Meeting',
                         FINANCIAL_PLAN_UPDATE__C = TRUE,
                         TAX_PLAN__C = FALSE,
                         IPS_UPDATED__C = TRUE,
                         Status__c = 'Canceled',
                         DurationInMinutes = 60));

    events.add(new Event(Subject = 'Tax Planning Meeting',
                         WhatID = accounts[8].Id,
                         ActivityDateTime = datetime.newInstance(2015, 8, 27, 12, 30, 0),
                         FSTR__SUB_TYPE__C = 'Tax Planning Meeting',
                         FINANCIAL_PLAN_UPDATE__C = TRUE,
                         TAX_PLAN__C = FALSE,
                         IPS_UPDATED__C = TRUE,
                         Status__c = 'Canceled',
                         DurationInMinutes = 60));

    events.add(new Event(Subject = 'Review Meeting',
                         WhatID = accounts[9].Id,
                         ActivityDateTime = datetime.newInstance(2015, 8, 28, 13, 30, 0),
                         FSTR__SUB_TYPE__C = 'Client Review Meeting',
                         FINANCIAL_PLAN_UPDATE__C = TRUE,
                         TAX_PLAN__C = TRUE,
                         IPS_UPDATED__C = TRUE,
                         Status__c = 'Canceled',
                         DurationInMinutes = 60));

     events.add(new Event(Subject = 'Tax Prep Meeting',
                         WhatID = accounts[10].Id,
                         ActivityDateTime = datetime.newInstance(2015, 8, 29, 14, 30, 0),
                         FSTR__SUB_TYPE__C = 'Tax Prep Meeting',
                         FINANCIAL_PLAN_UPDATE__C = FALSE,
                         TAX_PLAN__C = TRUE,
                         IPS_UPDATED__C = TRUE,
                         Status__c = 'Canceled',
                         DurationInMinutes = 60));                            

    Event event1 = new Event(Subject = 'Tax Planning Meeting',
                         WhatID = accounts[11].Id,
                         ActivityDateTime = datetime.newInstance(2015, 8, 30, 15, 30, 0));
                         event1.FSTR__SUB_TYPE__C = 'Tax Planning Meeting';
                         event1.FINANCIAL_PLAN_UPDATE__C = TRUE;
                         event1.TAX_PLAN__C = FALSE;
                         event1.IPS_UPDATED__C = TRUE;
                         event1.Status__c = 'Canceled';
                         event1.DurationInMinutes = 60;

    Test.startTest();
    insert events;
    update events;
    insert event1;
    update event1;
    Test.stopTest();

}
}
  • 2
    1) get rid of seeAllData=true - since you are mocking data, should not be required - and should only be used in really, really limited cases (like you need to test ContentVersionWorkspace). 2) Testmethod needs asserts to determine if your code is doing what it is supposed to do. Coide coverage by itself is not best practice – cropredy Oct 2 '15 at 19:44
  • also -- do you even know if the insert of Accounts and Events even succeeded? Maybe there was a validation error – cropredy Oct 3 '15 at 5:35
  • Got it to work! Thanks for your help! I did what you said and eventually realized that the Developer Console was not giving me the errors I received when I ran the test in the Salesforce interface, so I was able to debug from there. – hotblooded Oct 5 '15 at 16:09
  • hotblooded, do please accept (and upvote) any answer that helped you solve your question. Or answer your question yourself with the steps/solution you took to solve the problem. That will help others with similar questions. – Samuel De Rycke Oct 12 '15 at 14:09
1

I am going to surmise that your DML statements are returning errors and hence the test is not performing as you expect.

From a best practice point of view:

  1. get rid of seeAllData=true - since you are mocking data, should not be required - and should only be used in really, really limited cases (like you need to test ContentVersionWorkspace)
  2. In your testmethod, put try-catch around your mock data inserts/updates so you can assert that they execute as expected (that is, in the catch block: system.assert(false,'this shouldn't happen!'+e.getMessage());
  3. Use System.asserts to test the results of your trigger by requerying the database and verifying that updates to objects are done as you expect. This will aid you (and your estimable replacements) as you do maintenance over the months and years - knowing that the code continues to do as you expect

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.