とりあえず一通り簡単にチェックできるように実機テストを作ります
- ボタンなどに accessibilityIdentifierをつける
- accessibilityIdentifierを指定してボタンをタップする
アプリ名 + UITests と言うターゲットがあるのでそれを使います(初期化の時 Testも一緒に作る
fun testExample throws
左の緑のチェックは成功した時の印です。
最初は白枠の四角ボタン、それをクリックすると実機テストが始まります!

UITestsアプリがインストールされ実行されます。
対象アプリが起動してOK
次に、チェックしたい画面に遷移させてみます。
ButtonにaccessibilityIdentifierをつけた。
Button(action: {
}) {
Circle()
}
.accessibilityIdentifier("camera_shutterButton") func testTakePhoto() throws {
let app = XCUIApplication()
app.launch()
let loadingLabel = app.staticTexts["film_kod"]
XCTAssertTrue(loadingLabel.waitForExistence(timeout: 10))
// 3番目のボタン(リンク)をタップ
let oneButton = app.buttons.element(boundBy: 2)
oneButton.tap()
// 3番目のボタン(リンク)をタップ
let filterButton = app.buttons.element(boundBy: 40)
filterButton.tap()
// シャッターボタンが現れるのを確認
let shutterButton = app.buttons["camera_shutterButton"]
XCTAssertTrue(shutterButton.waitForExistence(timeout: 5))
shutterButton.tap()
sleep(10)
let albumButton = app.buttons["camera_albumButton"]
XCTAssertTrue(albumButton.waitForExistence(timeout: 10))
albumButton.tap()
sleep(10)
}一覧から撮影画面に遷移して撮影
保存を待ってアルバムを確認。
大丈夫でした◎



コメント