Wednesday, 11 September 2024

๐Ÿ“ ๐€๐ฉ๐ž๐ฑ ๐”๐ง๐ข๐ญ ๐“๐ž๐ฌ๐ญ ๐ญ๐ข๐ฉ๐ฌ ๐ž๐ฏ๐ž๐ซ๐ฒ ๐’๐š๐ฅ๐ž๐ฌ๐Ÿ๐จ๐ซ๐œ๐ž ๐๐ž๐ฏ ๐ฌ๐ก๐จ๐ฎ๐ฅ๐ ๐ค๐ง๐จ๐ฐ

 ๐Ÿ. ๐‚๐จ๐๐ž ๐ฌ๐ญ๐จ๐ซ๐š๐ ๐ž

You can save up to 6 MB of Apex code in each org, but test classes annotated with @isTest don’t count toward this limit.


๐Ÿ. ๐๐จ ๐ฌ๐ž๐ฉ๐š๐ซ๐š๐ญ๐ž ๐๐š๐ญ๐š๐›๐š๐ฌ๐ž ๐Ÿ๐จ๐ซ ๐ญ๐ž๐ฌ๐ญ๐ข๐ง๐ 

Even though test data rolls back, it still uses the same database. For objects with unique field constraints, inserting duplicates in tests can result in errors. Be careful!


๐Ÿ‘. ๐“๐ž๐ฌ๐ญ ๐ฆ๐ž๐ญ๐ก๐จ๐๐ฌ ๐๐จ๐ง’๐ญ ๐ฌ๐ž๐ง๐ ๐ž๐ฆ๐š๐ข๐ฅ๐ฌ

No worries about accidentally spamming your users. Test methods are safe from triggering emails.


๐Ÿ’. ๐๐จ ๐ž๐ฑ๐ญ๐ž๐ซ๐ง๐š๐ฅ ๐œ๐š๐ฅ๐ฅ๐จ๐ฎ๐ญ๐ฌ ๐ข๐ง ๐ญ๐ž๐ฌ๐ญ๐ฌ

Test methods can’t make callouts to external services, but you can use mock callouts to simulate API responses.


๐Ÿ“. ๐’๐Ž๐’๐‹ ๐ฌ๐ž๐š๐ซ๐œ๐ก๐ž๐ฌ

Any SOSL search in a test returns empty results by default. To ensure predictable results, 

use Test.setFixedSearchResults() to define the records you want.

No comments:

Post a Comment