rights reserved. テストピラミッド • The Test Pyramid • テストのバランスを⽰す指針 • 上から下にかけて数が増える • 上に⾏くほど⼿間がかかる 引⽤:https://martinfowler.com/articles/practical-test-pyramid.html
rights reserved. テストピラミッド • The Test Pyramid • テストのバランスを⽰す指針 • 上から下にかけて数が増える • 上に⾏くほど⼿間がかかる 引⽤:https://martinfowler.com/articles/practical-test-pyramid.html 今⽇はユニットテストとUIテストについてかいつまんで解説します%
rights reserved. HandGenerator.swift 「⼿」を抽選するクラス class HandGenerator { func generate() -> Hands { let i = Int.random(in: 0..<3) let hand = Hands(rawValue: i)! return hand } }
rights reserved. HandGenerator.swift class HandGenerator { func generate() -> Hands { let i = Int.random(in: 0..<3) let hand = Hands(rawValue: i)! return hand } } 「⼿」を返す
rights reserved. HandGenerator.swift class HandGenerator { func generate() -> Hands { let i = Int.random(in: 0..<3) let hand = Hands(rawValue: i)! return hand } } 乱数で抽選
rights reserved. HandGenerator.swift class HandGenerator { func generate() -> Hands { let i = Int.random(in: 0..<3) let hand = Hands(rawValue: i)! return hand } }
rights reserved. HandGenerator.swift class HandGenerator: Generator { func generate() -> Hands { let i = Int.random(in: 0..<3) let hand = Hands(rawValue: i)! return hand } }
rights reserved. PaperRockScissorsTest.swift class PaperRockScissorsTest: XCTestCase { class MockGenerator: Generator { var hand = Hands.paper func generate() -> Hands { return hand } } } テスト⽤のGeneratorクラス
rights reserved. PaperRockScissorsTest.swift class PaperRockScissorsTest: XCTestCase { class MockGenerator: Generator { var hand = Hands.paper func generate() -> Hands { return hand } } } 「⼿」は差し替え可能
rights reserved. UI要素の操作 同様に「⼿」も特定 let rock = app.images["my_hand_rock"] let paper = app.images["my_hand_paper"] let scissors = app.images["my_hand_scissors"] for hand in [rock, paper, scissors] { hand.tap() } それぞれの「⼿」をタップ
rights reserved. matchを設定 git_url("[email protected]:your_account/certificates.git") storage_mode("git") type("development") # The default type app_identifier(["us.shiroyama.SampleTest", "us.shiroyama.SampleTestUITests"]) username("Your Apple ID") % bundle exec fastlane match init vim fastlane/Matchfile UIテスト⽤のIdentifierを 忘れないこと % bundle exec fastlane match development ここで設定したパスワードをCircleCIの 環境変数MATCH_PASSWORDに設定
rights reserved. fastlaneでビルドとテストまで設定 default_platform(:ios) before_all do |lane, options| setup_circle_ci end platform :ios do desc "Build and Test" lane :build_and_test do match( type: "development", readonly: true, ) scan() end CircleCIでmatchを使う設 定 ビルドとテストが実⾏できる状態