Share
Embed
Transcript
18 slides
-
September 2023 New testing library announced in the Swift forums
• https://forums.swift.org/t/a-new- approach-to-testing-in-swift/67425 • A rich thread of more than 100 comments, sharing thoughts and experiences with the community • New forum category: https:// forums.swift.org/tag/swift-testing -
Who am I iOS Developer Consultant • Back to early
2013 • A fi rst experience with Eclipse IDE and Android SDK • Xcode 4.6 and an iPhone 4 • I’m sorry for those of you coming from the pre-ARC era 🦕 • Worked on IoT, video, banking and Cloud -
A decade of iOS development We’ve witnessed so many changes
• iOS 6: UIKit’s AutoLayout and the iPhone 5 • iOS 7: From skeuomorphic to fl at design • iOS 8: Hello Swift ! • iOS 13: Hello SwiftUI, and hello to you Combine as well • iOS 15: Swift Concurrency • iOS 17: Swift 5.8 - Macros -
Oldies but goodies XCTest has received some love over the
past decade • 2015: XCTestExpectation and and performance testing APIs: measureBlock {} • 2016: XCTAttachment • 2017: XCTContext.runActivity(named:block:) • 2019: XCTOSSignpostMetric for performance measuring • 2020: XCTAttachment(screenshot: ... ) • 2021: XCTMeasureOptions • 2022: XCTSkip • 2023: Hello XCTWaiter • Performance measuring • Attaching metadata • Test availability • Concurrency -
Vision for a modern Swift Testing API 4 principles •
Approachability • Expressivity • Flexibility • Scalability • https://github.com/apple/swift-testing/blob/main/Documentation/Vision.md -
import Testing Key points • Xcode/SPM Integration state • @Test
and @Suite • #expected and #required • Traits -
import Testing @Test and @Suite • Flexible test organisation •
Free standing global functions • Enclosing type acting as a test suite • Bye “test” pre fi x • Bye var myDependency: IWO! • Parameterized tests (N*M or zipping collections) -
import Testing Test Traits • Traits are a variadic parameter…
• Test availability at build time and run time • Time limit, measured in minutes • If applied to a @Suite, behaviour inherited to enclosed tests functions • If applied to a parameterized test, behaviour inherited to all test cases (each invocation separately) -
import Testing Test Traits • Comment, conforms to ExpressiblebyStringLiteral •
Tag, strongly typed to be even shared between test targets • Bug, aiming to work with bug report solutions • Yes, there’s a Bug in the type system now… (pun intended) • https://github.com/apple/swift-testing/blob/main/Sources/Testing/Traits/Bug.swift#L18 • Not to be confused with the Issue type, which seems to be internally used to collect information about failing tests -
import Testing WWDC 2024, we want feature parity! • System
integration: SPM and Xcode. • XCTestSca ff old already deprecated • Performance measurement • UI tests -
Nicolás García Let’s import a modern testing approach in Swift
Thank you ! Feel free to connect on LinkedIn