Skip to content
This repository has been archived by the owner on Mar 18, 2024. It is now read-only.

Enhancement: Allow for orchestrator validation job to skip certain classes #1279

Open
Stian-Schikora opened this issue Mar 27, 2023 · 5 comments
Labels
analysis To be decided on how to solution/fix apex-coverage

Comments

@Stian-Schikora
Copy link

Describe the bug
When i.e. integrating Salesforce to other systems. Rather than having to deal with complex data models being casted into Map<String, Object> it is much simpler to work with using the JSON.deserialize(jsonString, Wrapper.class). This causes us to create wrapper classes with no executable statements and only variables for the JSON data model to be casted into. By default, Salesforce code coverage does not count towards classes with no executables so it would be nice if the tool allowed to i.e. tag class with for example //Dx@Scale-novalidate to skip coverage requirement for certain classes.

To Reproduce
Create a class with no executable statements:

public class TestClass {
   private String variable;
}

Raise pull request with change and verify that validate command fails with 0% test coverage for new class.

@github-actions github-actions bot added the analysis To be decided on how to solution/fix label Mar 27, 2023
@azlam-abdulsalam
Copy link
Contributor

@Stian-Schikora this is a good idea, Can we write a DR on this? Probably it would be better if we could do this without any comments at all, by doing an apex parse run on it.

@nawforce have you looked into similar scenarios?

@nawforce
Copy link

Don't think this has come up before. There are a few cases you would need to think about re: 'no code', such as would that include having code in superclasses, what about property blocks, field initialisers and initialiser blocks. But mostly its just deciding what the rules are and writing some code to inspect the class after parsing to see if it fits that. There might also be some odd cases to deal with, such as a method that does nothing.

@azlam-abdulsalam
Copy link
Contributor

Thanks @nawforce. Will start with the comment as @Stian-Schikora suggested and then look into what are the rules

@ruslan-kurchenko
Copy link
Contributor

We went via a straightforward and dummy approach. In such a case, we create a private test visible method, which is empty, and a test method called coverage() calls such methods to satisfy the requirement.

@azlam-abdulsalam
Copy link
Contributor

@ruslan-kurchenko @Stian-Schikora further thoughts? close this one?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
analysis To be decided on how to solution/fix apex-coverage
Projects
None yet
Development

No branches or pull requests

4 participants