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
Mayank Srivastava (Salesforce fan)Mayank Srivastava (Salesforce fan) 

Why is the ID showing null in my System.assertEquals() statement?

In my test class, I am simply updating a list of custom object records (QA Release) and then I want to compare the field value of these newly inserted records in the list to the field values of Account object. I get the following error:
System.AssertException: Assertion Failed: Expected: Version0, Actual: null

The line which is causing this exception:
System.assertEquals(qaRels[i].Release_Version__c, accs[i].Production_Version__c);

To me, it seems like the accs[i].Production_Version__c is getting populated but the qaRels[i].Release_Version__c is returning Null even when it does have a value. 

Here is the code snippet. Can anyone please throw light on why the System.assert statement is failing?
 
for (Integer i=0; i<225; i++) {
     QA_Release__c qaRel  = new QA_Release__c();
     qaRel.Client__c             = accs[i].Id;
     qaRel.Objective__c          = 'New Build';
     qaRel.Due_Date__c           = Date.today();
     qaRel.Client_Site_Type__c   = 'Production';
     qaRels.add(qaRel);
     }
     insert qaRels;
     
     //This trick gives us a new set of Governor Limits
     Test.startTest();
     
     // Test1: Update QA Releases and fill out the delivered date (200+ records)
     
        for(Integer i=0; i<225; i++) {
        
        qaRels[i].Delivered_Date__c  = Date.today();
        qaRels[i].Release_Version__c = 'Version' + i;
        }
        update qaRels;
        
      qaRels =[SELECT Id,Release_Version__c FROM QA_Release__c];
      
              
                
        //Principle #2: Assert your results
         
     List<String> storeRelVer = new List<String>();
     for(Integer i=0; i<225; i++) {
     System.assertEquals(qaRels[i].Release_Version__c, accs[i].Production_Version__c);
     storeRelVer[i]=qaRels[i].Release_Version__c;
     }

 
Himanshu ParasharHimanshu Parashar
Hi,

System.asswerEquals is coming with expected value as "Version0" it means value is set fo this so can you please check acc list because acc[i].Production_version__c is coming null.


Thanks,
Himanshu