does swift testing support lazy properties for setup

Generated on 1/9/2025

1 search

Tailscan

This post is brought to you by Tailscan, the best devtool for Tailwind CSS.

Yes, Swift Testing supports lazy properties for setup. In Swift Testing, the types initializer is used for setup purposes, and it can be async or throw. This allows for the use of lazy properties to perform setup logic before each test runs. Additionally, deinitializers can be used to perform logic after each test, but they are only applicable when the suite type is an actor or class. This setup approach is part of the design to integrate seamlessly with Swift concurrency and to encourage the use of structs to isolate state.

For more details, you can refer to the session Meet Swift Testing (20:00).