Deployment on production Environment in salesforce
When we move any code or component on production environment we need to keep the below terms for our understanding:
These terms are-:
- Change Set : change sets are used to send customizations from one Salesforce org to another. Salesforce Change Sets are the mechanism by which changes from one Salesforce environment can be pushed into another Salesforce environment. Salesforce change set best practices means you’ll need to move changes out of an environment. You must first create an Outbound Change Set and point it towards a receiving environment.
- Inbound Change Set: An inbound change set in Salesforce is a change set that has been sent from another Salesforce org (Sandbox environment) to the org(production environment) you are logged in to. A change set must be deployed for the changes to take effect.
- Outbound Change set: An outbound change set in Salesforce is a change set created in the Sandbox environment in which you are logged in and to send to the production environment.
- Steps to use Change Sets in Salesforce
Find Deploy in Quick Find box -> Deployment Setting -> click Edit one of the sandbox and then enable checkbox for the Inbound change set and Outbound Change set
After Enable the checkbox please click on Save.
Follow these steps to give Outbound Change set from Sandbox org to Production Environment -:
- Setup -> search change set in quick find box -> click Outbound Change set.
2. Click on New Button.Enter Name, Description and click ‘Save’ Button.
3. Add ‘Change Set Components’ like Apex classes, Objects, Tabs, Validation Rule, Aura Components, Trigger… and Click on Add button.
4. After adding the components in the change set click on Upload Button.
5. After clicking on Upload Button please select a Production Environment like this:
6. After Select Production Environment click on the Upload Button. Then the change set is successfully uploaded to the Production Environment.
7. Ensure that the Allow Inbound change should be enable in production environment like this:
8. Now go to production and then select the outbound change Sets and Click Validate button.once the change set is validate then further proceed for the Deployment.
Test class in Salesforce:
Testing is an important part of SDLC.Salesforce requires at least 75% of your code to be covered by our test classes. Salesforce has done that to make sure that our code doesn’t break in any situation in Production.
It is a automation Testing which is provided salesforce by Default. when you write all the test cases in the test class then it will automatically test all the test cases.
when test cases are not covered in the given test class, then it will shown error like these which are described below:
- If you are giving the apex class or apex test class then ensure that the code coverage of the test class is 75% or more than 75%. If code coverage of the apex class is not accurate then you will be face this error like that:
2. In your Apex class there is found any error like duplicate Function, Name, Email or Expected or Actual Answer in test class or something else then error shows like this:
3. If found no error when validate your change set on production that means Change Set is Successfully validate and after that can start the deployment like that:
Please Refer this Module for more read about the Change set: