greased
greased copied to clipboard
R&D: @TestVisible alternative
Can an attribute contain a Object with fns (same design as the "test" object in Greased) provide a way to see private attributes and functions when populated.
If so, it could be populated only in test use and this would provide the same access model as @TestVisible
This needs to be testing and built if it works.
Something like @TestVisible would be awesome indeed. I don't think we can achieve it in a honest way. I'd be fine with that limitation for greased for the time being.
explanation:
If I understood correctly your approach seems to work around the issue in the literal sense. We wouldn't be testing the actual private attribute in the end. It also seems to me we would be asking developers to comply to certain ways of coding their components (again, if I understood correctly) in order to be testable with greased.
I agree. We recently discovered a nice alternative. That is to create another component which extends the component being tested and expose API fns from there. This component would be test only i.e. not deployed.
Once you have api fns in the sub-component, you have access to all the attributes and helper fns so now you can interact with them and return them if necessary. This has worked for us this week so I'll add it to the readme soon.