티스토리 뷰

보통 iphone se (1st) 가 가장 가혹한 UI환경 이므로 해당 기기에서  테스트 되도록 해야하고, 자동으로 빌드와 동시에 테스트 되도록 하는 스크립트를 가져와서 내 프로젝트에 맞게 수정한다. (자료를 포스팅 해준 뱅크샐러드에게 무한 감사)

 

 

1. 시뮬레이터 를 가져오는 스크립트 getSimulatorMatchingCondition.rb

require "json"

deviceName = ARGV[0]
runTime = ARGV[1]

json = JSON.parse(%x(xcrun simctl list 'devices' -j))
devices = json["devices"]["com.apple.CoreSimulator.SimRuntime.iOS-#{runTime}"]

if devices == nil
    puts "Error: 해당 OS를 만족하는 시뮬레이터가 설치되어 있지 않습니다"
else
    filteredDevices = devices.filter { |item| item["name"] == deviceName }

    if filteredDevices.empty?
        puts "Error: 해당 이름을 만족하는 시뮬레이터가 설치되어 있지 않습니다"
    else
        puts filteredDevices[0]["udid"]
    end
end

 

 

2. 해당 시뮬레이터를 찾아서 켜고 빌드와 테스트를 되도록 하느 스크립트 sh runSmokeTest.sh로 실행

# runSmokeTest.sh
# CI에서 SmokeTest를 실행하도록 하는 도구입니다.

# 마지막으로 실행했던 테스트 결과가 남아있다면 제거합니다
rm -rf resultBundle
rm -rf resultBundle.xcresult

SIMULATOR_NAME="iPhone SE (1st generation)"
SIMULATOR_OS = "15.4"
SIMULATOR_ID=$(ruby getSimulatorMatchingCondition.rb "$SIMULATOR_NAME" "15-4")
BUNDLE_ID="com.xxx.ActiveLabelTest"
BOOTED=$(xcrun simctl list 'devices' | grep "$SIMULATOR_NAME (" | head -1  | grep "Booted" -c)

open -a simulator

if [ $BOOTED -eq 0 ]
then
  # 아직 우리가 원하는 시뮬레이터카 안 켜져 있으면 켭니다.
  xcrun simctl boot $SIMULATOR_ID
fi

# 테스트를 실행하기 전에, 기존에 설치된 앱을 제거합니다.
xcrun simctl uninstall $SIMULATOR_ID $BUNDLE_ID

# 실제 테스트를 실행합니다.
set -e -o pipefail 
xcodebuild \
      -workspace ActiveLabelTest.xcworkspace \
      -sdk iphonesimulator \
      -scheme ActiveLabelTest \
      -destination "platform=iOS Simulator,id=$SIMULATOR_ID" \
      -derivedDataPath build\
      -resultBundlePath resultBundle\
      test | xcpretty
#xcpretty 는 이쁘게 sudo gem install xcpretty로 설치

 

3. 실행 화면

test result

 

댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2025/05   »
1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31
글 보관함