30 Mart 2021
Updated on 23 Temmuz 2024
Starting Unit Test with Swift
Çok önemli bir detay
article cover

1. Create Your Internal Class

I just created a super simple internal Model object in my brand new TestingTests project with one function:

A visual depiction of what is being written about

Again, notice that I’m not adding this model to my test target and not making the class or my method public!

2. Import with @testable

In your test target, just import the module you want to test using the @testable keyword:

A visual depiction of what is being written about
3. Test Away!

That’s it, now you can use all the internals of your class for testing purposes 🙂

A visual depiction of what is being written about

Thank you Swift team!

Subscribe to the newsletter
Get emails from me about web development, tech, and early access to new articles.
Be the first to know when the blog is published
;