Introducing Swift Testing
Swift Testing is a new framework with a new and refreshing approach to testing. Swift Testing contains modern features such as macros, which work with structs instead of classes and can tag tests and test suites.
Swift Testing is supposed to replace XCTest, which was introduced in 2013 as part of Xcode 5. XCTest belongs to older times when Objective-C was the dominant language. However, Swift took over, and Apple understood that iOS developers needed a modern testing framework.
Here’s a simple test function:
@Test("Test view model increment function", .enabled(if: AppSettings.CanDecrement), .tags(.critical)) func testViewModelIncrement() async throws { // preparation let viewmodel = CounterViewModel() viewmodel.count = 5 // execution ...