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

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