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
Garrett MillerGarrett Miller 

How can I use System.assert on a case basis?

Hi All, 


I am updating a field on one object based on another objects field being updated. They are "equal" in that they are contract lengths ranging from 1 year to 6 years. Unfortunately, the nature of my organization requires that for the field one object, the lanuage used is; annual, biennial, triennial, ... , sexennial. On the other object, the field is an integer from 1 to 6. 

My class just uses an if else to update the field to the string field. However, I am confused on how to perform this in the system.assert of my test class. I can't simply use:

System.assert(opp.Contract_Length__c == opp.Account.Renewal_Term__c, opp.Contract_Length__c+' is not equal to '+opp.Account.Renewal_Term__c);

As that would return 1 as not equal to Annual. Can I get some help on how to set up with portion of my test?

Best, 

Garrett