Skip to content

Commit 3793d01

Browse files
authored
Create swift-testing.md for XCTest tutorial
Added a new article on testing Swift applications using XCTest.
1 parent fe380f1 commit 3793d01

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

_articles/swift-testing.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
layout: page
3+
title: Swift Testing
4+
lede: "Testing Swift applications for iOS"
5+
---
6+
7+
## XCTest
8+
9+
### Verify an onboarding flow shows at first launch
10+
11+
```swift
12+
@MainActor
13+
func testOnboardingShowsAtFirstLaunch() throws {
14+
let app = XCUIApplication()
15+
app.launchArguments = ["-\(UserDefaultsKeys.onboardingCompleted)", "NO"]
16+
app.launch()
17+
18+
XCTAssertTrue(app.staticTexts["Some Onboarding Screen Text"].waitForExistence(timeout: 5)) // Wait for the first onboarding screen to show
19+
XCTAssertTrue(app.buttons["The Next Button"].exists)
20+
}
21+
```

0 commit comments

Comments
 (0)