Pro Yearly is on sale from $80 to $50! »

"XCTSkip your tests" の
要約 / xctskip_your_tests_summary

42a6a049ac8f5265f31858a9509217fb?s=47 uhooi
July 09, 2020

"XCTSkip your tests" の
要約 / xctskip_your_tests_summary

集まれSwift好き!Swift愛好会スピンオフ WWDC20セッション要約会 @オンライン
https://love-swift.connpass.com/event/181458/

## 参考リンク

- XCTSkip your tests - WWDC 2020 - Videos - Apple Developer
https://developer.apple.com/videos/play/wwdc2020/10164/

- XCTSkip | Apple Developer Documentation
https://developer.apple.com/documentation/xctest/xctskip

- XCTSkipIf(_:_:file:line:) | Apple Developer Documentation
https://developer.apple.com/documentation/xctest/3521325-xctskipif

- XCTSkipUnless(_:_:file:line:) | Apple Developer Documentation
https://developer.apple.com/documentation/xctest/3521326-xctskipunless

- swift-corelibs-xctest/XCTSkip.swift at master · apple/swift-corelibs-xctest
https://github.com/apple/swift-corelibs-xctest/blob/master/Sources/XCTest/Public/XCTSkip.swift

42a6a049ac8f5265f31858a9509217fb?s=128

uhooi

July 09, 2020
Tweet

Transcript

  1.  ໦  ू·Ε4XJGU޷͖ʂ4XJGUѪ޷ձεϐϯΦϑ88%$ηογϣϯཁ໿ձ!ΦϯϥΠϯ !UIF@VIPPJ 9$54LJQZPVSUFTUTͷ ཁ໿

  2. ΢ϗʔΠ J04ΞϓϦΤϯδχΞ w ࠓճݶఆͰ4XJGUѪ޷ձͷ ӡӦʹࢀը͍ͯ͠Δ

  3. ࠓ೔఻͍͑ͨ͜ͱ 9DPEFͰୈͷςετ݁Ռ͕௥Ճ͞Εͨ ੒ޭ ࣦഊ εΩοϓ

  4. ಛఆͷ৚݅ͷΈͰςετΛ ࣮ߦ͍ͨ͠ͱ͖Ͳ͏͢Δʁ

  5. ྫJ1BEͷΈͰςετΛ࣮ߦ͍ͨ͠ func test_iPadOnly_before() { // TODO: iPadઐ༻ͷςετΛ࣮ߦ͢Δ }

  6. #FGPSFʢ9DPEFະຬʣ func test_iPadOnly_before() { let isIPad = (UIDevice.current.userInterfaceIdiom == .pad)

    guard isIPad else { return } // TODO: iPadઐ༻ͷςετΛ࣮ߦ͢Δ } ৗʹ੒ޭѻ͍ʹ͢Δ
  7. "GUFSʢ9DPEFҎ߱ʣ func test_iPadOnly_after() throws { let isIPad = (UIDevice.current.userInterfaceIdiom ==

    .pad) guard isIPad else { throw XCTSkip("This tests are for iPad only") } // TODO: iPadઐ༻ͷςετΛ࣮ߦ͢Δ }
  8. #FGPSF "GUFS J1IPOFγϛϡϨʔλͰςετΛ࣮ߦ͢Δ ςετ࣮ߦ

  9. ςετΛεΩοϓ͢ΔϝϦοτ w εΩοϓͨ͠ࣄ࣮ͱཧ༝͕໌ࣔ͞ΕΔ w ࣄ࣮ৗʹ੒ޭѻ͍ʹ͢Δͱɺຊ౰ʹ੒ޭ͔ͨ͠Θ͔Βͳ͍ w ཧ༝εΩοϓͨ͠ཧ༝ΛจࣈྻͰࢦఆͰ͖ɺςετ݁Ռ͔Β֬ೝͰ͖Δ

  10. εΩοϓ͢Δํ๏͸छྨ͋Δ func test_iPadOnly_after() throws { let isIPad = (UIDevice.current.userInterfaceIdiom ==

    .pad) // ᶃ guard isIPad else { throw XCTSkip("This tests are for iPad only") } // ᶄ try XCTSkipIf(!isIPad, "This tests are for iPad only") // ᶅ try XCTSkipUnless(isIPad, "This tests are for iPad only") } ᶄͱᶅΛ࢖͍෼͚Δͷ͕ Αͦ͞͏
  11. ͓·͚಺෦࣮૷͕ެ։͞Ε͍ͯΔ Ҿ༻IUUQTHJUIVCDPNBQQMFTXJGUDPSFMJCTYDUFTUCMPCNBTUFS4PVSDFT9$5FTU1VCMJD9$54LJQTXJGU

  12. ࢀߟϦϯΫ w 4QFBLFS%FDLͷ֓ཁཝʹهࡌ