does swift testing support lazy properties for setup
Generated on 1/9/2025
1 search
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).
Platforms State of the Union
Discover the newest advancements on Apple platforms.
Go further with Swift Testing
Learn how to write a sweet set of (test) suites using Swift Testing’s baked-in features. Discover how to take the building blocks further and use them to help expand tests to cover more scenarios, organize your tests across different suites, and optimize your tests to run in parallel.
Meet Swift Testing
Introducing Swift Testing: a new package for testing your code using Swift. Explore the building blocks of its powerful new API, discover how it can be applied in common testing workflows, and learn how it relates to XCTest and open source Swift.
What’s new in Swift
Join us for an update on Swift. We’ll briefly go through a history of Swift over the past decade, and show you how the community has grown through workgroups, expanded the package ecosystem, and increased platform support. We’ll introduce you to a new language mode that achieves data-race safety by default, and a language subset that lets you run Swift on highly constrained systems. We’ll also explore some language updates including noncopyable types, typed throws, and improved C++ interoperability.