Closed ebuchman closed 6 years ago
I think it is a good practice in general, when enough of the functionality is exposed to test decently. It has forced me a number of times to modify the API, as some interesting functionality was only possible through private methods (even if only needed for test setup, very good to be able to set up tests in other packages).
I don't use it sometimes when there is lots of logic in private methods and it is not practical to test without it. Or out of laziness. But I think it is usually good practice.
cc @odeke-em
Thanks for the tag @zramsay!
Personally I prefer this style of X_test because as everyone has noted, it makes us test code through the public API. 2 other advantages:
With that being said, however, the comfort of the developer(Developer Experience) wins IMHO. We can slowly start adopting the style if everyone thinks it has more merit.
see #46
Often you need to call internal functions because to expose certain functions is bad. We should take care to expose only those functions that need to be exposed, so it becomes necessary to keep certain tests internal.
Use external packages for integration testing.
package X_test
forces you to do testing through the public interface. Most of our packages dont use it. When should they ?