Skip to content

Commit d98126c

Browse files
authored
ci: add ci (#1037)
* add ci * increase timeout * default timeout * tweak default arg * fix the usage * increased wdaLaunchTimeout * tweak tests * fix test
1 parent fd2e639 commit d98126c

24 files changed

+176
-24
lines changed

.github/workflows/functional-test.yml

+77
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
name: Functional Tests
2+
3+
on:
4+
# Run by manual at this time
5+
workflow_dispatch:
6+
push:
7+
branches: [ master ]
8+
pull_request:
9+
branches: [ master ]
10+
11+
concurrency:
12+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
13+
cancel-in-progress: true
14+
15+
jobs:
16+
ios_test:
17+
runs-on: macos-14
18+
env:
19+
XCODE_VERSION: 15.3
20+
IOS_VERSION: 17.4
21+
IOS_DEVICE_NAME: iPhone 15 Plus
22+
23+
steps:
24+
- uses: actions/checkout@v3
25+
26+
- name: Install Node.js
27+
uses: actions/setup-node@v3
28+
with:
29+
node-version: 'lts/*'
30+
31+
- name: Select Xcode
32+
uses: maxim-lobanov/setup-xcode@v1
33+
with:
34+
xcode-version: ${{ env.XCODE_VERSION }}
35+
- run: defaults write com.apple.iphonesimulator PasteboardAutomaticSync -bool false
36+
37+
- uses: futureware-tech/simulator-action@v3
38+
with:
39+
# https://github.com/actions/runner-images/blob/main/images/macos/macos-14-arm64-Readme.md
40+
model: ${{ env.IOS_DEVICE_NAME }}
41+
os_version: ${{ env.IOS_VERSION }}
42+
43+
- name: Preparing other environment
44+
run: |
45+
brew install ffmpeg
46+
brew tap wix/brew
47+
brew install applesimutils
48+
49+
# Start Appium
50+
- name: Install appium and mjpeg-consumer
51+
run: |
52+
npm install -g appium
53+
npm install -g mjpeg-consumer
54+
- run: |
55+
appium driver install xcuitest
56+
appium plugin install images@2.1.8
57+
appium plugin install execute-driver
58+
nohup appium --use-plugins=images,execute-driver --relaxed-security --log-timestamp --log-no-colors --base-path=/wd/hub > appium.log &
59+
60+
- name: Set up Ruby
61+
uses: ruby/setup-ruby@v1
62+
with:
63+
ruby-version: 3.2
64+
- run: |
65+
bundle install
66+
rake ios
67+
name: Run tests
68+
working-directory: ios_tests
69+
70+
- name: Save server output
71+
if: ${{ always() }}
72+
uses: actions/upload-artifact@master
73+
with:
74+
name: appium-ios_test_with_other_deps.log
75+
path: |
76+
appium.log
77+
test/report/

android_tests/lib/run.rb

-4
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,6 @@ def start_driver(caps)
4343
driver.start_driver
4444
end
4545

46-
# Sanity check
47-
a = OpenStruct.new x: 'ok'
48-
raise 'x issue' unless a.x == 'ok'
49-
5046
dir = File.expand_path(File.join(Dir.pwd, 'lib'))
5147
appium_txt = File.join(Dir.pwd, 'appium.txt')
5248
device = ARGV[0].downcase.strip

ios_tests/appium.txt

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
[caps]
22
platformName = "ios"
3-
platformVersion = "17.2"
4-
deviceName ="iPhone 15"
3+
platformVersion = "17.4"
4+
deviceName ="iPhone 15 Plus"
55
automationName = 'XCUITest'
66
app = "../test_apps/UICatalog.app.zip"
77
someCapability = "some_capability"
8+
simulatorStartupTimeout = 600000
9+
wdaLaunchTimeout = 600000
810

911
[appium_lib]
1012
wait = 30

ios_tests/lib/common.rb

+4
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ def catalog
3838
'UICatalog'
3939
end
4040

41+
def target_bundle_id
42+
'com.example.apple-samplecode.UICatalog'
43+
end
44+
4145
def ui_ios
4246
UI.new($driver)
4347
end

ios_tests/lib/ios/specs/common/command/command.rb

+3
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ class Common
1818
class Command
1919
class Command < Minitest::Test
2020
def test_01_command
21+
driver.terminate_app target_bundle_id
22+
driver.activate_app target_bundle_id
23+
2124
File.delete 'syslog.log' if File.exist? 'syslog.log'
2225

2326
# A number of systemlog is quite small than Android.

ios_tests/lib/ios/specs/common/element/window.rb

+2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ class Common
1919
class Element
2020
class Window < Minitest::Test
2121
def before_first
22+
driver.terminate_app target_bundle_id
23+
driver.activate_app target_bundle_id
2224
assert_equal screen, catalog
2325
end
2426

ios_tests/lib/ios/specs/common/helper.rb

+2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ def setup
2121
end
2222

2323
def test_01_before_first
24+
driver.terminate_app target_bundle_id
25+
driver.activate_app target_bundle_id
2426
assert_equal screen, catalog
2527
end
2628

ios_tests/lib/ios/specs/common/patch.rb

+2
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ class IosTest
2222
class Common
2323
class Patch < Minitest::Test
2424
def test_01_before_first
25+
driver.terminate_app target_bundle_id
26+
driver.activate_app target_bundle_id
2527
assert_equal screen, catalog
2628
end
2729

ios_tests/lib/ios/specs/common/web_context.rb

+2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ class IosTest
1919
class Common
2020
class WebContext < Minitest::Test
2121
def test_01_before_first
22+
driver.terminate_app target_bundle_id
23+
driver.activate_app target_bundle_id
2224
assert_equal screen, catalog
2325
end
2426

ios_tests/lib/ios/specs/device/device.rb

+2
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ def go_back
2424
end
2525

2626
def test_01_before_first
27+
driver.terminate_app target_bundle_id
28+
driver.activate_app target_bundle_id
2729
assert_equal screen, catalog
2830
end
2931

ios_tests/lib/ios/specs/device/image_comparison.rb

+2-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ def test_image_comparison
2424
# Equal to `$driver.driver.find_image_occurrence`
2525
# Equal to `driver.find_image_occurrence`
2626
find_result = find_image_occurrence full_image: image1, partial_image: image2
27-
assert_equal({ 'rect' => { 'x' => 0, 'y' => 0, 'width' => 750, 'height' => 1334 } }, find_result)
27+
rect = find_result['rect']
28+
assert_equal({ 'x' => 0, 'y' => 0, 'width' => 750, 'height' => 1334 }, rect)
2829
end
2930
end
3031
end

ios_tests/lib/ios/specs/driver.rb

+8-2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
class IosTest
1717
class Driver < Minitest::Test
1818
def test_01_before_first
19+
driver.terminate_app target_bundle_id
20+
driver.activate_app target_bundle_id
1921
assert_equal screen, catalog
2022
end
2123

@@ -95,7 +97,7 @@ def test_09_driver_class
9597
end
9698

9799
def test_10_status
98-
assert_equal appium_server_version['build'].keys.sort, %w(built git-sha version)
100+
assert appium_server_version['build'].keys.member?('version')
99101
end
100102

101103
def test_11_server_version
@@ -119,7 +121,7 @@ def test_14_driver
119121
end
120122

121123
def test_15_automation_name_is_xcuitest?
122-
assert_equal automation_name_is_xcuitest?, automation_name_is_xcuitest?
124+
assert_equal automation_name_is_xcuitest?, true
123125
end
124126

125127
#
@@ -189,5 +191,9 @@ def test_24_events
189191
log_event vendor: 'appium', event: 'funEvent'
190192
log_events
191193
end
194+
195+
def test_25_device_is_ios
196+
assert_equal device_is_ios?, true
197+
end
192198
end
193199
end

ios_tests/lib/ios/specs/ios/command/multi_app_handler.rb

+4-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@ class Command
1919
class MultiAppHandler < Minitest::Test
2020
# Only for Xcode 9+
2121
def test_multip_app_handler
22-
test_app_bundle = 'com.example.apple-samplecode.UICatalog'
22+
driver.terminate_app target_bundle_id
23+
driver.activate_app target_bundle_id
24+
25+
test_app_bundle = target_bundle_id
2326

2427
assert_equal xcuitest_query_app_status(bundle_id: test_app_bundle), :running_in_foreground
2528

ios_tests/lib/ios/specs/ios/command/pasteboard.rb

+3
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ class Ios
1818
class Command
1919
class Pasteboard < Minitest::Test
2020
def test_pasteboard
21+
driver.terminate_app target_bundle_id
22+
driver.activate_app target_bundle_id
23+
2124
# set blank before testing because pasteboard is remaining during launching simulators
2225
set_pasteboard content: 'before'
2326
assert_equal get_pasteboard, 'before'

ios_tests/lib/ios/specs/ios/element/alert.rb

+3
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ def open_alert
2525
end
2626

2727
def test_01_before
28+
driver.terminate_app target_bundle_id
29+
driver.activate_app target_bundle_id
30+
2831
assert_equal screen, catalog
2932
wait_true do
3033
find_element(:name, 'Alert Views').click

ios_tests/lib/ios/specs/ios/element/button.rb

+3
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ def after_last
3131
end
3232

3333
def test_01_before_first
34+
driver.terminate_app target_bundle_id
35+
driver.activate_app target_bundle_id
36+
3437
before_first
3538
end
3639

ios_tests/lib/ios/specs/ios/element/generic.rb

+3
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ def verify(element)
2727
end
2828

2929
def test_01_before_first
30+
driver.terminate_app target_bundle_id
31+
driver.activate_app target_bundle_id
32+
3033
assert_equal screen, catalog
3134
end
3235

ios_tests/lib/ios/specs/ios/element/text.rb

+3
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ def uiview_steppers
2626
end
2727

2828
def test_01_before_first
29+
driver.terminate_app target_bundle_id
30+
driver.activate_app target_bundle_id
31+
2932
assert_equal screen, catalog
3033
end
3134

ios_tests/lib/ios/specs/ios/element/textfield.rb

+3
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ def enter_password
2525
end
2626

2727
def test_01_before_first
28+
driver.terminate_app target_bundle_id
29+
driver.activate_app target_bundle_id
30+
assert_equal screen, catalog
2831
go_to_textfields
2932
end
3033

ios_tests/lib/ios/specs/ios/helper.rb

+3
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ class IosTest
1717
class Ios
1818
class Helper < Minitest::Test
1919
def test_01_before_first
20+
driver.terminate_app target_bundle_id
21+
driver.activate_app target_bundle_id
22+
2023
assert_equal screen, catalog
2124
end
2225

ios_tests/lib/ios/specs/ios/mobile_methods.rb

+2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ class IosTest
1717
class Ios
1818
class MobileMethods < Minitest::Test
1919
def test_01_before_first
20+
driver.terminate_app target_bundle_id
21+
driver.activate_app target_bundle_id
2022
assert_equal screen, catalog
2123
end
2224

ios_tests/lib/ios/specs/ios/patch.rb

+3-1
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@
1515
# rake "ios[ios/patch]"
1616
class IosTest
1717
class Ios
18-
class MobileMethods < Minitest::Test
18+
class Patch < Minitest::Test
1919
def test_01_before_first
20+
driver.terminate_app target_bundle_id
21+
driver.activate_app target_bundle_id
2022
assert_equal screen, catalog
2123
go_to_textfields
2224
end

ios_tests/lib/ios/specs/ios/xcuitest_gestures.rb

+2
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ def open_alert_custom
3131
end
3232

3333
def test_01_before_first
34+
driver.terminate_app target_bundle_id
35+
driver.activate_app target_bundle_id
3436
assert_equal screen, catalog
3537
end
3638

0 commit comments

Comments
 (0)