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

20171002Testing

 20171002Testing

#orecon_ios #ios_test_night

Shigure Shimotori

October 02, 2017
Tweet

More Decks by Shigure Shimotori

Other Decks in Programming

Transcript

  1. ͩΕ • @S_Shimotori / @S_Shimotori_pub • ৬ۀ: ֶੜ • GC΋ςετ΋ઐ໳Ͱ͸ͳ͍

    • iOSDCͰʮARC vs. GCʁARC in GCʁʯΛ΍Γ·ͨ͠ • ࠓ೔͸iOS Test Night࿮Ͱདྷ·ͨ͠
  2. ͱ͍͏͔୭΋ςετΛॻ͔ͳ͍ • ࣾձਓ͸ςετΛॻ͔ͳ͍ • ͕࣌ؒͳ͍ • ͦΜͳ͜ͱΑΓͬ͞͞ͱϦϦʔε͠Α͏ͥʂ • ֶੜ΋ςετΛॻ͔ͳ͍(ࢲΛؚΉ) •

    ͦ΋ͦ΋ςετͬͯԿͰ͔͢ʁ • ͦΕҎલʹΞϓϦ։ൃͬͯԿͰ͔͢ʁ • ςετͳΜ͔ॻ͍ͯͨΒ՝୊ఏग़ʹؒʹ߹Θͳ͍ ʘ(^o^)ʗ Φɹϫɹλ
  3. Apple͕ݴ͏ͱ͜Ζͷςετ • Testing with Xcode[2] • Xcodeͷ࢖͍ํ΍XCTest.frameworkͷ࿩ • ςετ͠΍͍͢ίʔυͱ͸Կ͔ʹ͍ͭͯ΋ड़΂ΒΕ͍ͯΔ •

    App Testing Guide[3] • ςετͷखॱ΍ΞϓϦʹෆ۩߹Λى͜͢ओͳݪҼҰཡͳͲ • ؔ࿈͢ΔଞͷΨΠυ΁ͷϦϯΫ͕๛෋ [2] https://developer.apple.com/library/content/documentation/DeveloperTools/Conceptual/testing_with_xcode/ [3] https://developer.apple.com/library/content/technotes/tn2431/_index.html XCTest.framework͕શͯͰ͸ͳ͍ʂ
  4. Θ͔ͨ͠Βͷ͓ئ͍ • ςετΛͯ͠ͳ͍ਓͳͲ͍ͳ͍ʂ • ͋ͳͨͷྡͷ੮ͷਓ΋͖ͬͱ׬ᘳʹ͸΍ͬͯͳ͍Α • iOS Test Nightʹ͓͍ͯ΋ಉ͡ •

    fastlane΋׬ᘳ͡Όͳ͍ͬͯgiginet͞Μ͕ݴͬͯͨ[4] • Կ͔औΓ૊Ή͜ͱ͕Ͱ͖ͨΒڞ༗͍ͯͩ͘͠͞ • ݶΒΕͨਓ݄Ͱط஌ͷ΋ͷΛಋೖ͢Δ͜ͱ΋஌ݟͷ1ͭ [4] https://speakerdeck.com/giginet/fastlane-contributordakedohe-kazhi-wen-aru
  5. ςετʹ΋ن͕֨͋Δ • ISO/IEC/IEEE 29119[5][6][7][8][9] • ιϑτ΢ΣΞςετͷࠃࡍج४Λఆٛͨ͠γϦʔζ5ຊͩͯ • ਤ͕ڵຯਂ͍ • ମ੍੔උͷ͖ͨͨ୆ɺ༻ޠूͱͯ͠࢖͑Δ…͔΋

    • ISO/IEC TR 19759:2015[10] • ιϑτ΢ΣΞશൠ • ଏʹSWEBOK • ֶߍ͕ISO/IECऔͬͯͳ͍ΜͰ͢୭͔ങͬͯ͋ͱC++΋ཉ͍͠(?) [5]http://ieeexplore.ieee.org/document/6588537/ [6]http://ieeexplore.ieee.org/document/6588543/ [7]http://ieeexplore.ieee.org/document/6588540/ [8]http://ieeexplore.ieee.org/document/7346375/ [9]http://ieeexplore.ieee.org/document/7750539/ [10]https://www.iso.org/standard/67604.html
  6. XCTestʹ͋Δ΋ͷ • Test Cases and Test Methods • Test Assertions

    • Asynchronous Tests • UI Tests • Activities and Attachments • Test Execution : XCTestͷجຊ෦෼ : Darwinಛ༗orޙ෇͚
  7. xUnit஀ੜ͔ΒXCTestʹࢸΔ·Ͱ • 1994೥ࠒʹK. Beck͕SUnitΛ࡞ͬͨͷ͕࢝·Γ • scripted testʹ᫣қ͍༷ͯͨ͠͝ࢠ • JUnit͸K. BeckΒ͕SUnitΛJavaʹҠ২ͨ͠΋ͷ

    • Python unittest͸JUnitͷ೿ੜ • JUnit4͸ΞϊςʔγϣϯΛ࠾༻͢ΔͳͲมΘͬͨ ڭ͑ͯৄ͍͠ਓ • 2005೥ͨͿΜ ɺXcode2.1͕OCUnitΛ࠾༻ • Objective-C༻ͷϑϨʔϜϫʔΫ • 2013೥ɺXcode5.0͕XCTestΛ࠾༻
  8. xUnitʹ͓͚Δ࣮૷ύλʔϯ • Fixture • TestCase΍setUpΛ࢖ͬͯڞ௨ͷςετ؀ڥΛ༻ҙ • Test Case • ࣮૷ɺೖྗɺظ଴݁Ռͷू߹Λ༻ҙ

    • ޓ͍ͷ݁ՌʹӨڹ͕ͳ͍ͷ͕ϛι • Check • ࣮݁Ռͱظ଴݁ՌΛൺֱ • ࣦഊͨ͠Β࣍ͷtest caseͷॲཧʹҠΔ • Test Suite • test caseͷू߹Λ؅ཧ͢Δ
  9. ྲྀߦΓͷϥΠϒϥϦΛݟͯΈΑ͏ʂ • ௐࠪର৅: ʮ2017೥Λࢧ഑͢ΔϥΠϒϥϦʯ[11]ଞ • UIϥΠϒϥϦͷςετ • εΫγϣͰݟ͔͑ͨΛ͔֬ΊΔ • ௨৴ςετ

    • ϓϩδΣΫτͷςετํ਑ • ςετίʔυࣗಈੜ੒ • ͓·͚: SPM༻ͷॲஔ [11]https://medium.com/app-coder-io/33-ios-open-source-libraries-that-will-dominate-2017-4762cf3ce449
  10. ࢒೦ͳ͓஌Βͤ • ਓؾͰظ଴גͷϥΠϒϥϦ != ͔ͬ͠ΓςετࡁΈ • ΍Δਓ͕͍ͳ͍͔Βʁςετ͢Δͷ͕೉͍͔͠Βʁ • ObjC൛Ͱςετͯ͠Swift൛Ͱςετͯ͠ͳ͍ྫ΋͋Δ •

    όάͳ͠Ͱಈ࡞͢Δอূ͸ͳ͍ • UI͕ਓؒͷ໨ʹݟ͑Δܗʹͳ͍ͬͯΔ͔Ͳ͏͔΋ಉ༷ • ࣮ࡍʹಈ͔ͯ͠Έͳ͍͜ͱʹ͸Θ͔Βͳ͍ https://github.com/nickoneill/PermissionScope https://github.com/ViccAlexander/Chameleon https://github.com/krzyzanowskim/Natalie https://github.com/dani-gavrilov/GDPerformanceView-Swift
  11. εΫγϣͰݟ͔͑ͨΛ͔֬ΊΔ • ࣮ࡍͷݟͨ໨·ͰνΣοΫ͍ͯ͠Δ͜ͱ΋͋Δ • ݁ہਓྗͰ໨ࢹ • εΫγϣΛࡱΔํ๏͸3छ • facebook/ios-snapshot-test-case •

    fastlane/fastlane/tree/master/snapshot • XCUIScreenshot https://github.com/danielgindi/Charts/blob/d300d6d332afa2e790fd616e5a8326e815b0e1f0/Tests/Charts/BarChartTests.swift
  12. ௨৴Λߦ͏ϥΠϒϥϦͷςετ • ௨৴ઌ͸Ͳ͔͜Βௐୡͯ͘͠Δͷ͔ʁ • ελϒΛ༻͍Δ • ishkawa/APIKit • AliSoftware/OHHTTPStubs→ಠ࣮ࣗ૷ •

    ࢖ͬͯ΋ౖΒΕͳ͍αʔό • onevcat/Hedwig • ϩʔΧϧˠϥΠϒϥϦ։ൃऀͷϝʔϧαʔόʔ(ʁ) • Alamofire/Alamofire • httpbin(1)
  13. ϓϩδΣΫτͷςετํ਑(mxcl/PromiseKit) • ݩΛͨͲΕ͹Promises/A+ • ཁ͔݅Βςετ·Ͱ༻ҙ͞Ε͍ͯΔ • ςετʹ߹֨͢Ε͹Promises/A+ͷϩΰΛܝࣔͰ͖Δ • ͜ΕͧBDD •

    PromiseKitͰ͸਌ϓϩδΣΫτ४ڌͷςετͱ
 ಠࣗͷςετͷ྆ํΛ͓͜ͳ͍ͬͯΔ • ࣗલͷdescribeϝιουΛۦ࢖ https://github.com/mxcl/PromiseKit/tree/master/Tests/A%2B https://github.com/promises-aplus/promises-tests/tree/master/lib/tests
  14. ͨͷ͍͠ࢀߟจݙ • Kent BeckʰBeck Testing Frameworkʱ<https://web.archive.org/web/20150315073817/http://www.xprogramming.com/ testfram.htm>ɼ(ࢀর2017-9-27) • Apple Inc.ʰXcode

    Release Notesʱ<https://developer.apple.com/library/content/releasenotes/DeveloperTools/RN-Xcode/>ɼ(ࢀ র2017-9-27) • Python Software Foundationʰ26.4. unittest — ϢχοτςετϑϨʔϜϫʔΫ — Python 3.6.1 υΩϡϝϯτʱ<https://docs.python.jp/ 3/library/unittest.html>ɼ(ࢀর2017-9-27) • খḺ૯߹σβΠϯࣄ຿ہʰʲ঎༻OKʳອը෩ϑϦʔૉࡐʮूதઢʯฤ 28ݸʲPNGɾAiʢIllustratorʣʳ | খḺ૯߹σβΠϯࣄ຿ہʛ ϗʔϜϖʔδ੍࡞ɾσβΠϯɾLINEελϯϓ੍࡞ʱ<http://otarunet.com/it/webdesign/comic-material-effect01/>ɼ(ࢀর2017-9- 18)ɽ