In a test, I load a static resource containing 17 records (rows) for my custom Case Assignment object.

A checkbox on this object is named Incorrect__c.

Three of the records have Incorrect__c of FALSE while the rest are TRUE:

List<sObject> caseAssignments = 
Test.loadData(Case_Assignment__c.sObjectType, 'Case_Assignments');

When I run the test containing the load above, the code below acquires the following coverage:

enter image description here

I can't figure out why correctAssignments++ doesn't execute, since there are definitely rows in the static resource that meet the else condition.

On further inspection via the debug log below, all the records in the static resource are in fact being read as having Incorrect__c equal to TRUE.

enter image description here

But like I said at the beginning of this question, the data in the static resource is as below:

enter image description here

Any ideas what's going on?

1 Answer 1


This is always true because it is an assignment whose resulting value is true:

if(ca.Incorrect__c = true){



or this:

if(ca.Incorrect__c == true){

should work.

  • 4
    This question (and thus answer) is the reason why I recommend never comparing a Boolean to true or false, but instead using it as a Boolean.
    – sfdcfox
    Jan 9, 2018 at 20:58

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .