While access control is a very welcome addition with many benefits, it can complicate unit testing, especially if you are new to unit testing. You probably know that you can apply the
testable
attribute to an import statement in a test target to gain access to entities that are declared as internal.While this is a convenient addition, it doesn’t give you access to private entities in a test target.
[…]
The key takeaway of this article is that private entities don’t need to be unit tested. Unit testing is a form of black-box testing. This means that we don’t test the implementation of the
AccountViewViewModel
struct, we test its specification.This doesn’t mean that we are not interested in the implementation, though. We need to make sure the suite of unit tests covers every code path of the entity we are testing. Code coverage reports are invaluable to accomplish this.
I don’t find this very persuasive.