Peter Gerald
Peter Gerald

Reputation: 68

Salesforce AssertEquals not working as expected

enter image description here

Why is this error thrown? I'm expecting it to pass.

Note : Without this assertion the code works perfectly fine.

Upvotes: 0

Views: 144

Answers (1)

TechingCrewMatt
TechingCrewMatt

Reputation: 526

I would try explicitly requesting the Last Name field in the SELECT clause as seen below:

for(Contact contact : [SELECT Id LastName, Name FROM Contact]){
    System.assertEquals(lastName, contact.LastName);
}

FYI, it would have been easier to answer this question if the code was in text and not an image.

Upvotes: 2

Related Questions