+ Start a Discussion
Sandra WicketSandra Wicket 

Error Message: System.AssertException:

Hi there, 
i want to upload my testclass or a new Trigger. Everytime i want to validate the testclas, i get this error message :

System.AssertException: Assertion Failed: Expected: 01sD0000000xxxxx, Actual: null 

The ID is a pricebook. Any advise ?  Thanks for your help guys.  The Code blow is my testclass 

public class UpdateLorAccRelatedtoTaskTest 
    static testMethod void testMethod1()
        Lead l = new Lead();
        l.LastName = 'Batman';
        l.LeadSource = 'Import';
        l.company ='Batman GmbH';
        l.country ='Deutschland';
        l.Status = 'qualified';
        l.PostalCode ='00000';
        l.Phone ='003030';
        l.LeadSource = 'Import';
        l.Time_Task__c = Date.valueOf('2013-05-05');
        insert l;

        Task t = new Task();
        t.whoId = l.Id;
        t.Status = 'Nicht Begonnen';
        t.priority = 'Normal';
        t.ActivityDate = Date.valueOf('2013-05-06');
        insert t; 
        t.ActivityDate = Date.valueOf('2013-05-07');
        update t;
        Account acc = new Account();
        acc.name = 'Test';
        acc.billingCountry = 'Deutschland';
        acc.billingPostalCode = '00000';
        acc.Type = 'Interessent';
        acc.Leadquelle__c = 'Import';
        acc.Time_Task__c = Date.valueOf('2013-06-05');
        insert acc;
        Task tt = new Task ();
        tt.whatId = acc.Id;
        tt.Status = 'Nicht Begonnen';
        tt.priority = 'Normal';
        tt.ActivityDate = Date.valueOf('2013-05-07');
        insert tt;
        tt.Subject = 'Demotermin2';
        tt.ActivityDate = Date.valueOf('2013-07-07');
        update tt;       
hi batman 
can you share your Trigger code?
Sandra WicketSandra Wicket
Hi Soni, 
here is the trigger ;) 

trigger UpdateLorAccRelatedtoTask on Task (before insert, before update) {
    for (Task t : trigger.new){
        if(t.WhoId != null){
            String WhoIdString = String.valueof(t.WhoId);

            if (WhoIdString.substring(0,3) == '00Q'){
                Lead lead = [SELECT Id, Time_Task__c FROM LEAD WHERE ID = :t.WhoId];

                    if(lead.time_task__c < t.ActivityDate){

                        lead.Time_task__c = t.ActivityDate;
                    update lead;
        else if (t.WhatId != null){
            String WhatIdString = String.valueof(t.WhatId);

            if (WhatIdString.substring(0,3) == '001'){
                Account acc = [SELECT Id, Time_Task__c FROM ACCOUNT WHERE ID = :t.WhatId];

                    if(acc.time_task__c < t.ActivityDate){

                        acc.time_task__c = t.ActivityDate;
                    update acc;
UC InnovationUC Innovation
Hi Batman,

Do you know where you are doing the System.assert() call. Since this is a System.AssertException you need to make sure that the value in 'Acutal' matches that of 'Expected'. Try following the line number provided in the debug logs to find the point where you run into the eecption and fix accordingly.

Hope this helps!

Sandra WicketSandra Wicket
Hi UC, 
thanks for your advice, but i have never tried something like that^^   Do i have to do a local run for the test class ?