Testability Tip for Swift Developers – Public Over Private
Read OriginalThis article discusses a common challenge in Swift unit testing: how to test private functions. It suggests viewing unit tests as clients of your code's API, emphasizing that only public code is easily testable. The author recommends using 'public' over 'private' or 'internal' access modifiers when possible, while acknowledging the benefits of encapsulation and compiler optimizations for private members. Practical advice is given on when to make code public, focusing on a type's core purpose. Aimed at Swift developers, it offers a testability tip to improve code observability and testing ease.
Comments
No comments yet
Be the first to share your thoughts!
Browser Extension
Get instant access to AllDevBlogs from your browser