I created an unlocked Salesforce package that contains an External Service and an Inactive Autolaunched Flow that calls methods in the External Service. The package does not contain any Apex classes other than those auto-generated when creating the External Service. However, I am unable to promote my package to a production release version because it is saying that I haven't met the code coverage requirements.

What needs to have code coverage? The External Service? The Flow?

I read that Flow testing requirements apply only when DEPLOYING them as active, but does that apply to packaging as well?

  • are there test classes for the auto-generated ones?
    – cropredy
    Apr 27 at 23:51
  • No. Shouldn't they also be auto-generated by Salesforce since it auto-generated the apex classes themselves? It wouldn't make sense to me that you would need to create test classes manually for something Salesforce is creating dynamically. But I'm not clear on how it works, which is why I'm asking! :-) Apr 28 at 14:19

1 Answer 1


If you are deploying apex classes, they must have code coverage (which should include asserts). It doesn't matter where the classes came from.

Here's one from the doc

public class MyAtmApexTest {
    static public void testMyAtmCallout() {
        // Set HTTP callout mock
        Test.setMock(HttpCalloutMock.class, new MyAtmHttpCalloutMock());
        // Call with the expected mock accountId and pin
        ExternalService.MyAtmExternalService myAtm = 
            new ExternalService.MyAtmExternalService();
        ExternalService.MyAtmExternalService.getBalance_Request request =
            new ExternalService.MyAtmExternalService.getBalance_Request();
        request.accountId = 'A123-456';
        request.pin = 1234;
        ExternalService.MyAtmExternalService_getBalance_OUT_200 actual = 

        // Assert the response variables
        ExternalService.MyAtmExternalService_getBalance_OUT_200 expected =
            new ExternalService.MyAtmExternalService_getBalance_OUT_200();
        expected.availableBal = 0;
        expected.name = 'Account Holder';
        expected.z0type = 'Checking';
        expected.accountId = 'A123-456';
        System.assertEquals(expected.toString(), actual.toString());
  • Ok. That makes sense. But when writing your test methods for the dynamically-generated External Service Apex class, how can you tell the percentage of code coverage you're achieving, since the dynamic apex class doesn't appear anywhere in the "Overall Code Coverage" tab in the Developer Console? Apr 28 at 20:29
  • I would imagine your IDE would tell you
    – cropredy
    Apr 28 at 23:21
  • When working with the project in VS Code, it's still showing "Org Wide Coverage" as 0%, even though my test methods are covering all of the external service methods. My guess is that Salesforce isn't reporting code coverage for the External Service because it's metadata, not code. But on the bright side, I was, however, able to promote the package to a release version. May 4 at 18:48

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .