sfpowerscripts
sfpowerscripts copied to clipboard
Enhancement: Allow for orchestrator validation job to skip certain classes
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 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?
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.
Thanks @nawforce. Will start with the comment as @Stian-Schikora suggested and then look into what are the rules
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 @Stian-Schikora further thoughts? close this one?