Apex Test Class Best Practices in Salesforce | how do you write a test class for Apex class in Salesforce

There are many points keep in mind whenever we write test class:-

To know more details about Test Class Best Practices, Click Here.

  • Use @isTest at the Top for all the test classes.
  • Avoid Using Hard Coding Ids anywhere in test Class
  • Use System.runAs() method to test the functionality in user Context
  • Check debug log. Make sure right tick must appear when you run your test class. Else check for errors.
  • Use Test.startTest() and Test.stopTest() statement to increase Governor Limits of your test code.
  • Use System.assertEquals() to see if your code has the expected outcomes
  • Test in bulk: Test to see if your code can run on 200 records at once. This is the maximum number of records that can be evaluated in a single trigger by Salesforce.
  • To deploy to production at-least 75% code coverage is required. and also the main functionality has been covered. If possible increase code coverage up to 95%.
  • We should not focus on the percentage of code coverage, we should make sure that every use case should covered including positive, negative,bulk and single record.
  • Test method should static and no void return type.
  • @Testvisible annotation to make visible private methods inside test classes.
  • Test method cannot be used to test web-service call out . Please use call out mock .
  • You can't send email from test method.
  • Use the @testSetup method to insert the common test data into the Test class that will flow all over the test class.
  • Do not put (seeAllData = true) in test class otherwise, use it for exceptional cases.

To know more live demo source code in Salesforce lightning, Trigger, Visualforce & LWC, Use this link..

Apex Test Class Best Practices in Salesforce | how do you write a test class for Apex class in Salesforce Apex Test Class Best Practices in Salesforce | how do you write a test class for Apex class in Salesforce Reviewed by Admin on 3:03 AM Rating: 5


  1. In this blog I get a great post please also visit my blog I post a great content

  2. Thanks For Sharing The Amazing content. I Will also share with my friends. Great Content thanks a lot.pinjarakhubsurtikaa

  3. your post is amazing and I really loved reading your post.
    Great Thanks for sharing awesome info. It was very well authored and easy to understand.
    I have a information about fake ID card. Idsbuddy is 𝐛𝐞𝐬𝐭 𝐟𝐚𝐤𝐞 𝐢𝐝 𝐰𝐞𝐛𝐬𝐢𝐭𝐞𝐬. You can learn more information about fake id from this website. you can check best fake id websites

  4. Thank for sharing, this is important to me, I invite you to discuss this topic Thane Escorts

  5. hello friends this site is the very popular and useful.matka

  6. WinASO Disk Cleaner This is a very helpful site for anyone, each and every man can easily operate this site and can get benefistss

  7. A proper kindly of research is very necessary before selecting the broker also we should keep in mind that reviews should not be trusted blindly, there should be someone who is from our friend circle who have worked with that broker bitforex

  8. I things and data online that you might not have heard before on the web.

    Hi, I found your site by means of Google

    indeed, even as searching for a comparative matter, your site arrived up, it is by all accounts incredible.

    bhai aapke liye hai. lagao or jeeto.I have bookmarked it in my google bookmarks.

    game is drawing and guisses based generally match-up,

    anyway currentlyit's arranged in best, and satta lord desawar is presently horribly eminent

    furthermore, to a great extent participating in game across the globe people ar insane with respect to this game.

    Yet, as of now the principal essential factor is that this game is satta king neglected to keep the law and

    decide guideline that to keep the conventions and rule. Presently right now people need to depend on it,

    on the off chance that the game doesn't follow the conventions they need not play the games anyway people are still

    partaking in the game,they play the games on the QT people have answer on it to quit participating

    in this kind of games, consistently help work and worked with individuals that might want facilitated,do something for

    your country do perpetually reasonable thing and be everlastingly happy.satta king

    Much obliged to you for visiting Our Website sattaking,Most most likely similar to our visitor from Google search.Maybe you are

    visting here to become more acquainted with about gali satta number today.to know gali disawar ka satta number please visting

    your landing page of site and look down . You will see boxed sorts data which is show satta number

    of particular game. There you will likewise see number of today yesterday satta number of, for example, gali disawar, new

    mumbai, disawar gold and loads of game you have wagered on the game.If you play your own gali disawar satta game and

    need us to put your own board on your website.Please satta king

    get in touch with us on showed number which you will discover in footer part of website.Apna game dalwane k liye hamse

    contact kre on google pay,phonepe, paytm jaise aap chahe pehle installment karen. aapka board moment site pr update

    kr diya jayega jaisi hey aapka installment done hota haiWe greet you wholeheartedly and exceptionally pleased to have you our

    website.satta kingPlease bookmark our site and stay tuned and refreshed to know.

    you might have perceived the cycle to play disawar satta gali game and caught wind of fix spill jodi disawar gali from

    your companions, family members. Actaully individuals favors disawar gali games as It is exceptionally well known in Indian subcontinent.

    also, is considered illegal.by having appended with our site .satta kingYou

    will discover magnificient content in regards to all the games.satta king We have staggering

    data of satta results and gali disawar diagrams as the are open for public and refreshed.


header banner -- www.w3web.net

Powered by Blogger.