Should tests break the Law of Demeter?
Jeremy Nagel
1

I think you are right, “_resetColumnOrientation” is private and really shouldn’t be tested. Calling (or relying on) private methods in test is no less of a problem than calling them from other code.

In this case, all the code outside the view cares about is that the view has the correct column orientation. It does not (indeed, should not) care if a method called “_resetColumnOrientation” exists or needs to exist or gets called on initialisation or not. In the future it could be refactored to get called lazily on the first “render”, or the need for it could be removed all together. The view would still behave the same way (and behave correctly), but if we had an invasive test the test would fail.

When code is refactored and behaves the exact same way it used to (with the same public interface), but your tests break, then you know you were testing the wrong thing.