Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Swiftの単体テスト事情
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
CyberAgent
PRO
June 03, 2024
Programming
290
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Swiftの単体テスト事情
24卒のFlutter&iOSエンジニアです。現在WinTicketでFlutterエンジニアをしています。
CyberAgent
PRO
June 03, 2024
Transcript
32 slides
Swift Testing CA.swift 5/30 naruogram
自己紹介 株式会社WinTicket 新卒入社 名前: なるお 技術: Flutter, Swift X: @naruogram
GitHub: @naruogram
はじめに
Swift Testingを調査した背景 - 研修メンバーに、Swift経験者がほとんどいなかった ため、直感的にテストを書きたいと思った - XCTestの学習コストが高い
目次 - Swift Testingについて - Swift Testing 特徴と活用
Swift Testingについて
Swift Testing Appleが発表したUnit Testライブラリ 強力で表現力豊かな機能を備えた、Swift 用の最新のオー プンソース テスト ライブラリです。(※公式説明より抜粋) ※
Swift5.9から対応 ※ Xcodeには統合されていない 参照元: https://github.com/apple/swift-testing
Swift Testing 特徴 - 柔軟で簡単 - カスタマイズ - 拡張性
Swift Testing 特徴と活用
Swift Testing 特徴1: 柔軟で簡単
Swift Testing 特徴1: 柔軟で簡単 テスト宣言したい場合: @Testを使用 テスト検証したい場合: #expectを使用
Swift Testing 特徴1: 柔軟で簡単 nilの場合にテストを失敗させたい場合: #requireを使用する requireがあることにより失敗の原因特定スピード向上します
Swift Testing 特徴1: 柔軟で簡単 テストのグループ化をしたい場合: @Suite
Swift Testing 特徴1: 柔軟で簡単 Concurrencyに関連するテスト XCTestと比較し、より簡単に記述が可能
Swift Testing 特徴2: カスタマイズ
Swift Testing 特徴2: カスタマイズ Traitsについて テストに特性を追加して注釈を付けたり、 動作をカスタマイズしたりします。
Swift Testing 特徴2: カスタマイズ Traitsを組み合わせることで柔軟なテストへ
Swift Testing 特徴2: カスタマイズ キャンペーンを実施している時のみ テストしたい場合
Swift Testing 特徴2: カスタマイズ Traitsの.enableを使用することで可能になる enableはif文を使ってテストの実行可否を決めれる
Swift Testing 特徴2: カスタマイズ CI等でテストが失敗した時に ログを残したい場合
Swift Testing 特徴2: カスタマイズ 失敗時のログに残すための表示方法
Swift Testing 特徴2: カスタマイズ 特定のバグをテストに関連付けたい場合
Swift Testing 特徴2: カスタマイズ Traitの.bugを使用し、関連付けをする。 明示的にバグで落ちてることがわかる
Swift Testing 特徴2: カスタマイズ Bug RelationShip種類 .uncoveredBug: バグが発見された時 .reproducesBug: 以前からのバグを実証する時
.verifiesFix: バグが修正され、バグが再現されない時 .failingBecauseOfBug: 無関係なバグが発生した時 .unspecified: その他
Swift Testing 特徴2: カスタマイズ 一時的に特定のテストを実行したくない場合
Swift Testing 特徴2: カスタマイズ テストの重要度を分類したい場合
Swift Testing 特徴2: カスタマイズ Traitのtagsを使用することで分類化 明示的にテストの重要度などを表現できる
Swift Testing 特徴3: 拡張性
Swift Testing 特徴3: 拡張性 引数のみを切り替えて テストを実行したい場合 (パラメタライズドテスト)
Swift Testing 特徴3: 拡張性 引数のみを切り替えて実行するテスト メリット: 1メソッドで多くのテストケースを 網羅できる ※ デフォルトでパラメタライズドテストの
機構が含まれている
Swift Testing まとめ - XCTestに比べて、より簡単にできる - 最近のSwiftの機能により順応している - Swift TestingはBetaなので、今後に期待
ありがとうございました!
More Decks by CyberAgent
See All by CyberAgent
AWS ハンズオン研修 2026
cyberagentdevelopers
PRO
7
8.7k
IBC 2026 動画技術関連レポート / IBC 2026 Report
cyberagentdevelopers
PRO
2
480
AIを使った広告商品の開発と評価設計の話
cyberagentdevelopers
PRO
1
110
動画広告の効果を技術で改善
cyberagentdevelopers
PRO
1
120
なぜWINTICKETはマイクロサービスをやめたのか
cyberagentdevelopers
PRO
3
170
”AIを使う” から ”AIに任せる” へ ─ 開発プロセスを再設計してAIを組織標準にするまで
cyberagentdevelopers
PRO
2
470
Databricks 導入から Genie 活用まで、全部やった話
cyberagentdevelopers
PRO
0
2.1k
専任DEゼロからの データ基盤構築 - Databricks x IaC x AIで 進める「データの民主化」-
cyberagentdevelopers
PRO
1
1.5k
「エンジニア進化論」2028年の開発完全自動化、エンジニアはどう進化するか
cyberagentdevelopers
PRO
10
10k
Other Decks in Programming
See All in Programming
[DroidKnights 2026] Workflow AX: From Auto-Documented Policies to E2E Testing
raeminkang
0
610
protojson における文字化けの扱い
kazuki1023
0
460
Agentic AI with the Power of Jakarta EE
ivargrimstad
0
180
Growing PicoRuby's Ecosystem on ESP32
yuuu
2
150
Debian JP Projectのサーバー構成
uwabami
1
180
Enforcing Your Architecture with Unit Tests in the AI Era (Swift Connection X)
steliosf
PRO
1
190
LLM 101: Exploring LLMs, Starting with Tokens.
dalinaum
0
120
AI駆動TDD ― 2026年10月版
hrmstrsmgs
0
110
SONY CISC-NEWS NWS-1750 + NWB-225 ハードウェアメンテとフレームバッファカラー対応 / KOF2026
tsutsui
0
130
複数ドメインを一つのアプリに統合するFlutterの設計と運用_FlutterKaigi2026登壇資料(須永高弘)
takahirosunaga
0
210
TanStack Vue Query と Pinia Colada から学ぶ非同期状態の型設計
aoshi
0
700
Ruby から Emacs を操作したい
phigasui
0
390
Featured
See All Featured
The SEO Collaboration Effect
kristinabergwall1
1
630
Fashionably flexible responsive web design (full day workshop)
malarkey
409
67k
Bioeconomy Workshop: Dr. Julius Ecuru, Opportunities for a Bioeconomy in West Africa
akademiya2063
PRO
1
470
Introduction to Domain-Driven Design and Collaborative software design
baasie
1
1.1k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
333
23k
Beyond borders and beyond the search box: How to win the global "messy middle" with AI-driven SEO
davidcarrasco
3
310
A Tale of Four Properties
chriscoyier
163
24k
How STYLIGHT went responsive
nonsquared
100
6.4k
The Spectacular Lies of Maps
axbom
PRO
1
1.1k
Become a Pro
speakerdeck
PRO
31
6.4k
Embracing the Ebb and Flow
colly
88
5.2k
StorybookのUI Testing Handbookを読んだ
zakiyama
31
7.1k