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
sieb4mesieb4me 

test class

can anyone please tell me if itsw mandatory to deploy test class in production?
Best Answer chosen by thisisnotapril
MJ Kahn / OpFocusMJ Kahn / OpFocus
If you're deploying Apex code to Production, unit tests for that code must also be developed and deployed. During deployment of any Apex code, Salesforce automatically runs all unit tests in Production, and all of the following conditions must be met, or your deployment will fail:
  • All unit tests must run to completion without uncaught failures.
  • The tests must touch at least 75% of all Apex code.
  • The tests must touch all triggers
These rules don't apply to code in managed packages.

See the Apex Language Reference (http://www.salesforce.com/us/developer/docs/apexcode/salesforce_apex_language_reference.pdf), specifically the chapter on Testing Apex, for details.

All Answers

MJ Kahn / OpFocusMJ Kahn / OpFocus
If you're deploying Apex code to Production, unit tests for that code must also be developed and deployed. During deployment of any Apex code, Salesforce automatically runs all unit tests in Production, and all of the following conditions must be met, or your deployment will fail:
  • All unit tests must run to completion without uncaught failures.
  • The tests must touch at least 75% of all Apex code.
  • The tests must touch all triggers
These rules don't apply to code in managed packages.

See the Apex Language Reference (http://www.salesforce.com/us/developer/docs/apexcode/salesforce_apex_language_reference.pdf), specifically the chapter on Testing Apex, for details.
This was selected as the best answer
BerginBergin
Yes, the test class must be deployed and it should contribute to the overall coverage of >75%