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

Popular posts from this blog

Salesforce Fact #192 | Call batch apex from flow

Salesforce Fact #457 | Get current user role name in flow