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
Janno RipJanno Rip 

Estimated Code Coverage 82% but Deployment fails with 73%

Hello everyone,

I am a total newbie when it comes to apex test classes and code coverage. I took over an org where a lot of customizing was done. When i hit "Estimate your organization's code covearge" it says:
User-added imageBefore that I was running tests on all our test classes.

Now I've build something on our sandbox and tried to deploy it. But I am getting the following error:

User-added image
Are these two different things? 

What can i do to get more than 73%? Write test classes for existing apex classes?

Thanks in Advance
Jan

Best Answer chosen by Janno Rip
Jayesh_TejwaniJayesh_Tejwani
From the Winter '19 (https://releasenotes.docs.salesforce.com/en-us/winter19/release-notes/rn_forcecom_flow_deploy_as_active.htm) release notes:

In production orgs, a new setting lets you deploy a new active version of a process or flow via change sets or Metadata API. This setting doesn't appear in non-production orgs (such as scratch, sandbox, and developer orgs), because you can always deploy a new active version.

When you deploy an active process or flow in a production org, Salesforce runs your org’s Apex tests and confirms that enough of your processes and flows have test coverage. Specifically, the Apex tests must launch at least 75% of the total number of active processes and active autolaunched flows in your org.


Spring '19 (https://releasenotes.docs.salesforce.com/en-us/winter19/release-notes/rn_forcecom_flow_test_coverage.htm) introduces some enhancements to how you can test processes and flows, and also allows you to track coverage more easily:

If your org uses Apex tests to validate processes and autolaunched flows, you’re probably interested in knowing what your flow test coverage is. We’re introducing two Tooling API objects that you can query to calculate test coverage for processes and autolaunched flows.

If you're not using the new tool to deploy Flows as active, you don't need to worry about coverage level.

My best suggestion which I recently tried is deploy processes/flow by making it inactive

Please vote if you find this as best answer!!

All Answers

Jayesh_TejwaniJayesh_Tejwani
From the Winter '19 (https://releasenotes.docs.salesforce.com/en-us/winter19/release-notes/rn_forcecom_flow_deploy_as_active.htm) release notes:

In production orgs, a new setting lets you deploy a new active version of a process or flow via change sets or Metadata API. This setting doesn't appear in non-production orgs (such as scratch, sandbox, and developer orgs), because you can always deploy a new active version.

When you deploy an active process or flow in a production org, Salesforce runs your org’s Apex tests and confirms that enough of your processes and flows have test coverage. Specifically, the Apex tests must launch at least 75% of the total number of active processes and active autolaunched flows in your org.


Spring '19 (https://releasenotes.docs.salesforce.com/en-us/winter19/release-notes/rn_forcecom_flow_test_coverage.htm) introduces some enhancements to how you can test processes and flows, and also allows you to track coverage more easily:

If your org uses Apex tests to validate processes and autolaunched flows, you’re probably interested in knowing what your flow test coverage is. We’re introducing two Tooling API objects that you can query to calculate test coverage for processes and autolaunched flows.

If you're not using the new tool to deploy Flows as active, you don't need to worry about coverage level.

My best suggestion which I recently tried is deploy processes/flow by making it inactive

Please vote if you find this as best answer!!
This was selected as the best answer
Janno RipJanno Rip
Hello Jayesh_Tejwani,

thanks for your reply. In the end I managed to achieve the deployment. I still had 1 Apex Error that I could not fix so far - until i did. After deactiviting some process / Flows - checking/unchecking the checkbox wheter new process/flows should be inactive or active the error message disappeared. 

Greetings
Jayesh_TejwaniJayesh_Tejwani
Great thanks, please mark my answer as best answer if it helped you. Thanks