When we move any code or component to the 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 sent to the production environment.

- Steps to use Change Sets in Salesforce
Find Deploy in Quick Find box -> Deployment Setting -> click Edit one of the sandboxes and then enable the checkbox for the Inbound change set and Outbound Changeset

After Enabling 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 Changeset.

2. Click on the New Button. Enter the changeset Name, and Description and click the ‘Save’ Button.

3. Add ‘Change Set Components’ like Apex classes, Objects, Tabs, Validation Rule, Aura Components, and Trigger… and Click on the Add button.


4. After adding the components to 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 enabled in a production environment like this:

8. Now go to production and then select the outbound change Sets and Click the Validate button. Once the change set is validated 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 an automation Testing that is provided by 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 show errors like these which are described below:
Note:
- 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 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 the test class or something else then the error shows like this:

3. If no error when validating your change set on production that means Change Set is Successfully validated and after that can start the deployment like that:

Please Refer to this Module for more read about the Change set:
https://trailhead.salesforce.com/en/content/learn/modules/declarative-change-set-development
2 Responses