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/ での発表資料です。

B765faf519f19520e1495bd870f4d7f0?s=128

PoohSunny

May 22, 2017
Tweet

Transcript

  1. XCUITest͢Δ࣌ͷ TIPs ʙ͋ͳͨΛॿ͚ΔXCUITest΁ʙ @PoohSunny iOS Test Night #4

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

    community: [ "TDDBC", "Agile Samurai Base Camp", "೔ຊSeleniumϢʔβʔίϛϡχςΟ" ] }
  3. Selenium޷͖1 1 ग़ॴɿٕज़ධ࿦ࣾ

  4. iOSॳΊͯ̍೥ ʢποίϛ׻ܴʂʣ

  5. ΑΖ͘͠ ͓ئ͍͠·͢

  6. UITestͷ࿩

  7. None
  8. XCUITest ࢖͍ͬͯ·͢

  9. TIPsͷ঺հ ଞͷςετϑϨʔϜϫʔΫͰ΋࢖͑Δ͸ͣʂ

  10. TIP1 Ͳ͜·Ͱςετ͢Ε͹͍͍Μ ͩorz

  11. εϞʔΫςετ

  12. 1. جຊతͳಈઢ 2. མͪΔͱॏେো ֐ʹͳΔ෦෼

  13. TIP2 UIΛมߋͨ͠Βͨ͘͞Μͷς ετ͕͚ͯ͜͠·ͬͨorz

  14. ϖʔδΦϒδΣΫτύλʔϯ Λར༻ͨ͠มߋͷہॴԽ ςετର৅ͷϖʔδΛΦϒδΣΫτͱͯ͠ςετ ͔Β੾Γ཭͠ɺϝϯςφϯεੑΛߴΊΔ2 2 http://www.seleniumhq.org/docs/06testdesign_considerations.jsp#page-object-design-pattern

  15. ཁ໿3 • publicϝιου->ϖʔδ͕ఏڙ͢ΔαʔϏεΛ දݱ • ϖʔδͷ಺෦Λ࿐ग़͠ͳ͍Α͏ʹ͠·͢ • ҰൠతʹɺΞαʔγϣϯ͸ߦ͍·ͤΜ • ϝιου͸ผͷPageObjectsΛฦ͠·͢

    3 http://garbagetown.hatenablog.com/entry/2013/11/07/075011͔ΒҾ༻
  16. σΟϨΫτϦ UITest |-- Module // ֤ϖʔδͰڞ௨͢Δ෦඼܈ |-- Screen // ϖʔδΦϒδΣΫτ

    `-- Test // ࣮ࡍͷςετέʔε
  17. αϯϓϧ 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) } }
  18. TIP3 ͜ͷςετԿͯ͠Δͷ͔Θ͔ ΜͶʔorz

  19. ςετͷՄಡੑΛ্͛Δ ྫ͑͹ར༻ϝιου໊Λ೔ຊޠʹ͢Δ func testۈ຿஍Λબ୒͢Δ() { let τοϓϖʔδ = TopScreen(xcuiApplication: XCUIApplication())

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

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

    TopScreen(xcuiApplication: XCUIApplication()) // when let ݕࡧ݁Ռϖʔδ = τοϓϖʔδ.Լه৚݅Ͱݕࡧ͢Δ(Area.౦ژ, "ϑϦʔϫʔυ") // then XCTAssert(ݕࡧ݁Ռϖʔδ.දࣔ͞Ε͍ͯΔ()) }
  22. 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
  23. ·ͱΊ • TIP1. Ͳ͜·Ͱςετ͢Δ͔໎ͬͨΒεϞʔΫ ςετ • TIP2. มߋΛہॴԽ͍ͨ͠ͳΒϖʔδΦϒδΣ Ϋτύλʔϯ •

    TIP3. ՄಡੑΛ্͍͛ͨͳΒ೔ຊޠΛ࢖͏ͷΛ ԀΘͳ͍
  24. ͓͠·͍ ʙ͋ͳͨΛॿ͚ΔXCUITest΁ʙ