Salesforce Fact #63 | test class tip
It is always a best practice not to use org data in test class. Instead we should create our own data for testing.
However,
if we need to get a particular record during our testing we can get
that using SOQL. But the records will be like read only. Any changes
made to the record in the test class would not be reflected in the
original record.
In this example, we are fetching one account
named 'test' in the test class. Now, although we are changing the name
of the account and also updating the same, also the assert is
successful, the original record is unchanged.
Attached are the screenshots.
Comments
Post a Comment