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 reframes unit tests as clients of an API, arguing that only public code is easily testable. The author recommends using the 'public' access modifier over 'private' or 'internal' when possible to improve testability, while acknowledging the benefits of encapsulation and compiler optimizations for private code. The tip is aimed at Swift developers practicing Test-Driven Development.
Comments
No comments yet
Be the first to share your thoughts!
Browser Extension
Get instant access to AllDevBlogs from your browser