Closed ShotaKashihara closed 4 years ago
https://github.com/wantedly/yashima-ios/pull/6585/files
全部で3ステップ
plugins_path = File.join(File.dirname(__FILE__), 'fastlane', 'Pluginfile')
eval_gemfile(plugins_path) if File.exist?(plugins_path)
bundle install
Firebase CLI をインストール
npm install firebase-tools
Fastfile に step を追加
firebase_app_distribution(
app: <<firebase_app_id>>,
groups: "wantedly-1,developers-1",
release_notes: "branch: #{git_branch}.\ncommit: #{last_git_commit[:message]}",
firebase_cli_path: "./node_modules/.bin/firebase"
)
突然ですが、明日お邪魔させていただくことになりました。 よろしくお願いします。
もしWatendlyさんで「パラメタライズドテスト(テーブル駆動テスト)」についてトピックを取り上げたことがなかったら、他社の勉強会の使い回しで恐縮ですが、以下について発表させていただきたいです。 https://gist.github.com/uhooi/6715b32d8e936e122816e2d069a0356c
一部を転記します。
テストケースは何パターン必要?
func canWork(motivation: Int, hasRedBull: Bool) -> Bool {
if motivation < 100 {
return false
}
if !hasRedBull {
return false
}
return true
}
motivation | hasRedBull | return value |
---|---|---|
99 | true | false |
99 | false | false |
100 | true | true |
100 | false | false |
一覧表に○×を付けるのが一般的
No | motivation | hasRedBull | return value | 判定 | 日付 | 担当 |
---|---|---|---|---|---|---|
1 | 99 | true | false | OK | 2019/11/29 | ウホーイ |
2 | 99 | false | false | OK | 2019/11/29 | ウホーイ |
3 | 100 | true | true | NG | 2019/11/29 | ウホーイ |
4 | 100 | false | false | OK | 2019/11/29 | ウホーイ |
func test_canWork_motivation_99_hasRedBull_true() {
let logic = LogicSample()
XCTAssertFalse(logic.canWork(motivation: 99, hasRedBull: true))
}
func test_canWork_motivation_99_hasRedBull_false() {
let logic = LogicSample()
XCTAssertFalse(logic.canWork(motivation: 99, hasRedBull: false))
}
func test_canWork_motivation_100_hasRedBull_true() {
let logic = LogicSample()
XCTAssertTrue(logic.canWork(motivation: 100, hasRedBull: true))
}
func test_canWork_motivation_100_hasRedBull_false() {
let logic = LogicSample()
XCTAssertFalse(logic.canWork(motivation: 100, hasRedBull: false))
}
保守されなくなる
motivation | hasRedBull | return value |
---|---|---|
99 | true | false |
99 | false | false |
100 | true | true |
100 | false | false |
let tests: [(motivation: Int, hasRedBull: Bool, expect: Bool)] = [
( 99, true, false),
( 99, false, false),
(100, true, true ),
(100, false, false)
]
func test_canWork() {
let tests: [(line: UInt, motivation: Int, hasRedBull: Bool, expect: Bool)] = [
(#line, 99, true, false),
(#line, 99, false, false),
(#line, 100, true, true ),
(#line, 100, false, false)
]
for (line, motivation, hasRedBull, expect) in tests {
let logic = LogicSample()
let result = logic.canWork(motivation: motivation, hasRedBull: hasRedBull)
XCTAssertEqual(result, expect, line: line)
}
}
このように、引数のみを切り替えて実行するテストを 「 パラメタライズドテスト 」という
言語によって呼び方が異なることがある
言語 | 名前 |
---|---|
Go | テーブル駆動テスト |
Java | パラメータ化テスト |
他言語では一般的なのに、なぜかSwiftでは知られていない…
@tobi462さんの資料がとても参考になります
Swift で ParameterizedTest をやってみた話/swift-parameterized-test - Speaker Deck
https://speakerdeck.com/yusukehosonuma/swift-parameterized-test
Swiftでも、SpockのData Tablesのように書きたい!
class MathSpec extends Specification {
def "maximum of two numbers"(int a, int b, int c) {
expect:
Math.max(a, b) == c
where:
a | b | c
1 | 3 | 3
7 | 4 | 7
0 | 0 | 0
}
}
演算子のオーバーロードとFunction Buildersで実現できないかな…
参考
http://spockframework.org/spock/docs/1.3/data_driven_testing.html#data-tables
https://swiftwithmajid.com/2019/11/27/combine-and-swiftui-views/
@uhooi このちょっとした工夫良いですね! 😄 https://github.com/uhooi/yumemi-swift-5-sample/commit/c19b4025f611278139400e71a70d6f27872d45aa
@hedjirog ありがとうございます! この工夫自体は参考にさせていただいた資料とほとんど同じなのですが、あまり広まっていないようなので発表しようと思いました😌
おつかれさまでした! 良い回だったと思います!
良い会でしたね!
⚠️ This repository is public. / 公開リポジトリです。
Why
Where
Pearl Jam (Subject to change)
5F, MG Shirokanedai Building (Wantedly, Inc. Tokyo HQ)
Who
You are working for Wantedly? Sure, you can join anytime. If not, you need to contact us first. Or, you can "want to visit" the meetup, which you can find in www.wantedly.com/companies/wantedly/projects.
What
You write topics like below contents and we talk about these on the meetup. Every participant needs to write one topic at least.
Also, you can find new topics from the newsletters:
How
・・・
参加者は開催までに話したいことを少なくとも1トピックをコメントしましょう。 ネタ被りを避けるために、まずはタイトルだけでコメントすることを推奨します。 より多くの学びを得るためにどんな内容でもアウトプットを歓迎します!😊
cc/ @wantedly/ios
Edit this template
Previous issue
https://github.com/wantedly/ios_night/issues/76