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
ariella nothariella noth 

Help with Assertion Failed

Im working on a test class, and this chunk below is resulting in an Assertion Failed error. Its returning as "Expected 1, Actual Null" 

 //Insert our first task
        Task t = new Task(subject='Test Activity', whoId = leds.id);
        insert t;
        
        //Verify count
        leds = [SELECT ID, Number_of_Activities__c FROM Lead WHERE ID = :leds.id];
        System.assertEquals(1,leds.Number_of_Activities__c);

Any help is appreciated.
Raj VakatiRaj Vakati
Number_of_Activities__c is formula field ? or its a number filed .. 
 
Task t = new Task(subject='Test Activity', whoId = leds.id);
        insert t;
        
		Lead l = new Lead() ;
		l.LastName ='Test' ;
		// .. Add other fields 
		l.Number_of_Activities__c  =1 ;
		insert l ; 
		
        //Verify count
        Lead leds = [SELECT ID, Number_of_Activities__c FROM Lead WHERE ID = :l.id];
		// If Number_of_Activities__c not  a formula update it with one 
		leds.Number_of_Activities__c = 1 ; 
		
        System.assertEquals(1,leds.Number_of_Activities__c);