Andrew Bancroft 4/15/2015

Testability Tip for Swift Developers – Public Over Private

Read Original

This 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.

Testability Tip for Swift Developers – Public Over Private

Comments

No comments yet

Be the first to share your thoughts!

Browser Extension

Get instant access to AllDevBlogs from your browser