How to define implementation details?
- by woni
In our project, an assembly combines logic for the IoC-Container, the project internals and the communication layer.
The current version evolved to have only internal classes in addin assemblies.
My main problem with this approach is, that the entry point is only available over the IoC-Container. It is not possible to use anything else than reflection to initialize the assembly.
Everything behind the IoC-Interface is defined as implementation detail and therefore not intended for usages outside.
It is well known that you should not test implementation detail (such as private and internal methods), because they should be tested through the public interface.
It is also well known, that your tests should not use the IoC-Container to setup the SUTs, because that would result in too much dependencies.
So we are using the InternalsVisibleTo-Attribute to make internals visible to our test assemblies and test the so called implementation details.
I recognized that one problem could be the mixup between different concerns in that assembly, changing this would make this discussion useless, because classes have to be defined public.
Ignoring my concerns with this, isn't the need to test a class enough reason to make it public, the usages of InternalsVisibleTo seems unintended, and a little bit "hacky".
The approach to test only against the publicly available IoC-Container is too costly and would result in integration style tests.
The pros of using internals are, that the usages are well known and do not have to be implemented like a public method would have to be (documentation, completeness, versioning,...).
Is there a solution, to not test against internals, but keep their advantages over public classes, or do we have to redefine what an implementation detail is.