Upgrade to Pro — share decks privately, control downloads, hide ads and more …

XCUITestする時のTIPs 〜あなたを助けるXCUITestへ〜

XCUITestする時のTIPs 〜あなたを助けるXCUITestへ〜

iOS Test Night #4 https://testnight.connpass.com/event/54316/ での発表資料です。

PoohSunny

May 22, 2017
Tweet

More Decks by PoohSunny

Other Decks in Technology

Transcript

  1. @PoohSunny { work: "σΟϕϩούʔ", company: "ϦΫϧʔτδϣϒζ", lang: ["Swift", "Java", "Groovy"],

    community: [ "TDDBC", "Agile Samurai Base Camp", "೔ຊSeleniumϢʔβʔίϛϡχςΟ" ] }
  2. αϯϓϧ class TopScreen: BaseScreen { required init(xcuiApplication: XCUIApplication) { super.init(xcuiApplication:

    xcuiApplication) XCTAssert(app.navigationBars["τοϓ"].exists) } func ݕࡧϘλϯΛԡ͢() -> BaseScreen { app.navigationBars.buttons.elementBoundByIndex(0).tap() return ResultScreen(xcuiApplication: xcuiApplication) } }
  3. ςετͷՄಡੑΛ্͛Δ ྫ͑͹ར༻ϝιου໊Λ೔ຊޠʹ͢Δ func testۈ຿஍Λબ୒͢Δ() { let τοϓϖʔδ = TopScreen(xcuiApplication: XCUIApplication())

    τοϓϖʔδ.౎ಓ෎ݝΛબ୒͢Δ(Area.౦ژ) let ݕࡧ݁Ռϖʔδ = τοϓϖʔδ.ݕࡧ͢Δ() XCTAssert(ݕࡧ݁Ռϖʔδ.දࣔ͞Ε͍ͯΔ()) }
  4. ϖʔδΦϒδΣΫτΛ ࡞ΓࠐΉ func testۈ຿஍Λબ୒͢Δ() { let τοϓϖʔδ = TopScreen(xcuiApplication: XCUIApplication())

    let ݕࡧ݁Ռϖʔδ = τοϓϖʔδ.Լه৚݅Ͱݕࡧ͢Δ(Area.౦ژ, "ϑϦʔϫʔυ") XCTAssert(ݕࡧ݁Ռϖʔδ.දࣔ͞Ε͍ͯΔ()) }
  5. Given-When-Thenҙࣝͯ͠ ΈΔ func testۈ຿஍Λબ୒͢Δ() { // given let τοϓϖʔδ =

    TopScreen(xcuiApplication: XCUIApplication()) // when let ݕࡧ݁Ռϖʔδ = τοϓϖʔδ.Լه৚݅Ͱݕࡧ͢Δ(Area.౦ژ, "ϑϦʔϫʔυ") // then XCTAssert(ݕࡧ݁Ռϖʔδ.දࣔ͞Ε͍ͯΔ()) }
  6. 4 phase test4Ͱ΋ Setup - Exercise - Verify - Teardown

    3A5Ͱ΋ Arrange - Act - Assert 5 http://xp123.com/articles/3a-arrange-act-assert/ 4 http://xunitpatterns.com/Four%20Phase%20Test.html