Hacker News new | ask | show | jobs
by selfhoster11 1643 days ago
I agree with this. FWIW, Java (for instance) could treat testing as a privileged mode of execution, allowing for all properties (even private ones) to be get/set/interacted with as if they were public, for the duration of the test. This would simplify so many things and get rid of so much boilerplate code.
1 comments

I agree actually and was thinking that visibility modifiers should not really deny access for the internals of the class under testing. Maybe c++’s friend classes would be a good solution? Or I don’t really find groovy to be the best thing, but it could probably be hacked to translate private accesses to reflection calls under the hood making testedClass.privateField actually callable?