launchdarkly / apex-server-sdk

LaunchDarkly Server-side SDK for Salesforce Apex

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Code Coverage Failure

jitenderpadda opened this issue · comments

Describe the bug
Getting code coverage error on the following classes and hence unable to deploy to higher environments. Am I missing something here? I used version 1.1.0 -

  • Your code coverage is 70%. You need at least 75% coverage to complete this deployment.
    LD_Evaluator
  • Your code coverage is 60%. You need at least 75% coverage to complete this deployment.
    LD_EventREST
  • Your code coverage is 54%. You need at least 75% coverage to complete this deployment.
    LD_LDConfig
  • Your code coverage is 47%. You need at least 75% coverage to complete this deployment.
    LD_LDClient
  • Your code coverage is 62%. You need at least 75% coverage to complete this deployment.
    LD_LDValue
  • Your code coverage is 0%. You need at least 75% coverage to complete this deployment.
    LD_StoreREST
  • Your code coverage is 66%. You need at least 75% coverage to complete this deployment.
    LD_VersionedData

image

Just deployed original SDK 1.1.0 and ran tests -

image

To reproduce

  • sfdx force:source:convert -d deployment
  • sfdx force:mdapi:deploy -d deployment --testlevel RunSpecifiedTests --runtests "DataModelTest,DataStoreTest,EvaluationReasonTest,EvaluatorOperatorTest,EvaluatorTest,EventProcessorTest,EventRESTTest,EventSinkTest,EventTest,LDClientTest,LDUserTest,LDValueTest,SemanticVersionTest"

Expected behavior
All code should have 75% plus code coverage and the SDK should be deploy ready

SDK version
apex-server-sdk-1.1.0

Hello @jitenderpadda, thank you for reaching out. It seems there are two separate questions here - why the deployment is not working, and this Apex SDK's code coverage.

This is a bit weird because when I install only the classes from this SDK to a brand new development org (i.e. no other Apex that affects the calculation), it has 80% coverage.
Screen Shot 2022-02-11 at 2 38 57 PM

And based on some discussion from the Salesforce StackExchange forum, if your other Apex code already has 75% coverage or more, the LaunchDarkly SDK will not bring down the average to the point that it blocks deployment.

Also, can you provide more information on how do you come up with the reproduction commands? I try running it against a dev org, but I just get 0% for every class, which is different from what you get.
Screen Shot 2022-02-11 at 2 47 35 PM

@louis-launchdarkly Thanks for getting back to me. I updated the command in the question - I have namespaced the classes with LD_ so had to remove that.

On the code coverage issue, I believe it's failing because I am running specified tests and not all tests. Each Apex component needs 75% coverage if we are running specified tests -
image

Tried deploying to a brand new dev org using RunSpecifiedTests and got the same errors -
image

Tried deploying to a brand new dev org using RunLocalTests and it succeeded -
image

Unfortunately for us, we cannot run all tests because this is an old org. Is it possible for you guys to push each class coverage above 75% so that it becomes more usable?

Hello @jitenderpadda, while there is some clean-up we want to do and I think it is reasonable to increase coverage, at this point I cannot provide a timeframe yet. I will mark this as an enhancement and track it.

In terms of installing, I recommend you file a Support ticket with our Support team. They are more familiar with the SDK setup process and may have other suggestions for you.

Filed Internally as 143027.

Hi @jitenderpadda, this should be resolved by 1.3.0. Feel free to open another issue if not.