sfpowerscripts icon indicating copy to clipboard operation
sfpowerscripts copied to clipboard

Enhancement: Allow for orchestrator validation job to skip certain classes

Open Stian-Schikora opened this issue 1 year ago • 5 comments

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.

Stian-Schikora avatar Mar 27 '23 06:03 Stian-Schikora

@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?

azlam-abdulsalam avatar Apr 25 '23 00:04 azlam-abdulsalam

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.

nawforce avatar Apr 29 '23 17:04 nawforce

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

azlam-abdulsalam avatar May 15 '23 13:05 azlam-abdulsalam

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.

ruslan-kurchenko avatar May 19 '23 10:05 ruslan-kurchenko

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

azlam-abdulsalam avatar Jun 29 '23 03:06 azlam-abdulsalam