Do you know xctest command?

0d04162c7a3c2907c059a06dbcd23cf4?s=47 tokorom
January 15, 2014

Do you know xctest command?

XCTest.frameworkじゃなくてxctestコマンド
xctestコマンドを直接叩いてCUIから任意のテストだけ実行するのにトライしてみた

0d04162c7a3c2907c059a06dbcd23cf4?s=128

tokorom

January 15, 2014
Tweet

Transcript

  1. xctestίϚϯυͬͯ ஌͍ͬͯ·͔͢ʁ ॴ ༑ଠ @tokorom iOS App Programer These are

    “not” confidential sessions—please diffuse by your blogging and twitter potatotips #3
  2. ༧૝ • XCTestϑϨʔϜϫʔΫ͸஌͍ͬͯΔ • xctestίϚϯυͳΜͯ͋Δͷʁ

  3. Xcode 5 ʹͳͬͯ • xcodebuildίϚϯυ͕௒ઈύϫʔΞοϓʂ • XcodeͰಛఆͷςετέʔε͚ͩΛୟ͘ͷ͕؆ ୯ʹͳͬͨ

  4. Ͱ΋ • xcodebuildίϚϯυʹಛఆͷςετΛࢦఆ͢Δ ޱ͕ͳ͍ • ී௨ʹ͸CUI͔ΒಛఆͷςετΛ࣮ߦ͢Δํ๏ ͕ͳ͍ʂʂ

  5. xctestίϚϯυͱ͸ʁ • xcodebuild test ͸಺෦తʹ xctest ίϚϯυΛୟ ͍͍ͯΔ •xctest -XCTest

    SampleTests/testSample Ͱ࣮ߦ͢ Δςετέʔε͕ࢦఆͰ͖Δ
  6. ͨͩ͠… • xctestίϚϯυΛTerminalͰ௚઀ୟ͍࣮ͯߦ͢ Δͱ͔͸ৗਓʹ͸΄΅ෆՄೳ •΅͘͸ xctest Λ௚઀ୟ͍ͯςετ࣮ߦ͢Δͷʹ ؙ̎೔͔͔ؒͬͨ

  7. น1: ͲͷxctestΛୟ͘ͷʁ

  8. xctest͸͍͔ͭ͋͘Δ $ pwd /Applications/Xcode.app ! $ find . -name xctest

    ./Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/ iPhoneSimulator7.0.sdk/Developer/usr/bin/xctest ! ./Contents/Developer/usr/bin/xctest Xcode͔ΒͩͱϏϧυͨ͠όΠφϦʹ߹Θͤͯద੾ͳ΍ ͕ͭ࢖ΘΕ͍ͯΔͬΆ͍
  9. น2: ϏϧυઃఆͷҾ͖ܧ͗

  10. xcodebuild -showBuildSettings • ͜ΕͰϏϧυઃఆΛ֬ೝ͍ͯ͠Ζ͍Ζมߋ͠ ͳ͍ͱμϝ •build settings ͸xcodebuildʹ౉͢ଞͷΦϓγϣ ϯʹΑͬͯมΘΔͷͰ஫ҙʂʂ

  11. น3: ؀ڥม਺ͷઃఆ

  12. NSProcessInfo • NSProcessInfoΛ࢖ͬͯςετ࣮ߦ࣌ʹઃఆ͞ Ε͍ͯΔ؀ڥม਺ͱ͔ίϚϯυͷҾ਺ͱ͔͕෼ ͔Δ •͜Ε΋build settings ͷ಺༰ʹΑͬͯద੾ʹઃఆ ͢Δඞཁ͕͋Δ

  13. ཁ͢Δʹී௨ʹୟ͘ͷ͸ແཧ

  14. ͳͷͰϥΠϒϥϦԽ͠·ͨ͠ʂ

  15. xctest-runner

  16. xctest-runner $ gem install xctest-runner ! $ xctest-runner ! $

    xctest-runner -test SampleTests/testSample
  17. xctest-runner $ xctest-runner -scheme Tests ! $ xctest-runner -project Sample.xcodeproj

    -target Tests
  18. (Vimͱ͔emacs͔Βฤूதͷςετ ͚࣮ͩߦͱ͔Ͱ͖ΔΑ͏ʹͳΔʂʣ

  19. None
  20. More Information Yuta ToKoRo! iOS App Programer! @tokorom! ! http://www.tokoro.me/

    https://github.com/tokorom/xctest-runner