Skip to content

Commit d104623

Browse files
authored
Add running func tests for iOS on Azure (#210)
* extend azure * update * tweak readme
1 parent ecd16c3 commit d104623

11 files changed

+412
-261
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
[![Gem Version](https://badge.fury.io/rb/appium_lib_core.svg)](https://badge.fury.io/rb/appium_lib_core)
44

5-
| Travis, Ubuntu | Azure, Windows |
5+
| Travis, Ubuntu | Azure, Windows and functional tests |
66
|:---:|:---:|
77
|[![Build Status](https://travis-ci.org/appium/ruby_lib_core.svg?branch=master)](https://travis-ci.org/appium/ruby_lib_core)|[![Build Status](https://dev.azure.com/kazucocoa/ruby_lib_core_windows/_apis/build/status/appium.ruby_lib_core)](https://dev.azure.com/kazucocoa/ruby_lib_core_windows/_build/latest?definitionId=4)|
88

azure-pipelines.yml

+22-22
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,25 @@
22
# Package your Ruby project.
33
# Add steps that install rails, analyze code, save build artifacts, deploy, and more:
44
# https://docs.microsoft.com/azure/devops/pipelines/languages/ruby
5-
pool:
6-
vmImage: 'vs2017-win2016'
7-
8-
variables:
9-
UNIT_TEST: true
10-
11-
steps:
12-
- task: UseRubyVersion@0
13-
inputs:
14-
versionSpec: '2.4.3'
15-
16-
- script: gem install bundler ffi:1.10.0
17-
displayName: 'Gem install bundler and ffi for Windows environment'
18-
19-
- script: bundle install --retry=3 --jobs=4
20-
displayName: 'Call bundle install'
21-
22-
- script: gem uninstall --force eventmachine && gem install eventmachine --platform ruby
23-
displayName: 'bundle re-install eventmachine for Windows because of Windows environment issue'
24-
25-
- script: parallel_test test/unit/ -n 4
26-
displayName: 'Run parallel_test test/unit/ -n 4'
5+
jobs:
6+
- template: ./ci-jobs/functional_test.yml
7+
- job: Run_unit_tests_on_Windows_environment
8+
pool:
9+
vmImage: 'vs2017-win2016'
10+
variables:
11+
UNIT_TEST: true
12+
steps:
13+
- task: UseRubyVersion@0
14+
inputs:
15+
versionSpec: '2.4.3'
16+
- script: gem install bundler ffi:1.10.0
17+
displayName: 'Gem install bundler and ffi for Windows environment'
18+
- script: bundle install --retry=3 --jobs=4
19+
displayName: 'Call bundle install'
20+
- script: gem uninstall --force eventmachine && gem install eventmachine --platform ruby
21+
displayName: 'bundle re-install eventmachine for Windows because of Windows environment issue'
22+
- script: parallel_test test/unit/ -n 4
23+
displayName: 'Run parallel_test test/unit/ -n 4'
24+
- template: ./ci-jobs/functional/publish_test_result.yml
25+
parameters:
26+
xcodeVersion: 'Run_unit_tests_on_Windows_environment'

ci-jobs/functional/ios_setup.yml

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
steps:
2+
- script: sudo xcode-select -s /Applications/Xcode_${{ parameters.xcodeVersion }}.app/Contents/Developer
3+
displayName: Xcode Select ${{ parameters.xcodeVersion }}
4+
- task: NodeTool@0
5+
inputs:
6+
versionSpec: 11.x
7+
displayName: Install Node 11.x
8+
- script: xcrun simctl list
9+
displayName: List Installed Simulators
10+
- script: npm install -g appium@beta
11+
displayName: Install appium beta
12+
- task: UseRubyVersion@0
13+
inputs:
14+
versionSpec: '2.4' # so far, bundler does not work over 2.5 since it raises openssl error
15+
- script: appium --relaxed-security &
16+
displayName: Run Appium in background
17+
- script: |
18+
gem install bundler;
19+
bundle install --retry=3 --jobs=4 --path vendor/bundle;
20+
displayName: Install Gems
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
steps:
2+
- task: PublishTestResults@2
3+
condition: always()
4+
inputs:
5+
testResultsFiles: 'test/reports/TEST-AppiumLibCoreTest*.xml'
6+
testRunTitle: ${{ parameters.title }}

ci-jobs/functional_test.yml

+119
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
# jobs for functional test
2+
jobs:
3+
# Run unit tests on different Node versions
4+
- job: func_test_ios_base
5+
pool:
6+
vmImage: 'macOS-10.14'
7+
variables:
8+
CI: 'true'
9+
steps:
10+
- template: ./functional/ios_setup.yml
11+
parameters:
12+
xcodeVersion: 10.1
13+
- script: |
14+
bundle exec rake test:func:ios TEST=test/functional/ios/driver_test.rb
15+
bundle exec rake test:func:ios TEST=test/functional/ios/patch_test.rb;
16+
displayName: Run tests
17+
- template: ./functional/publish_test_result.yml
18+
parameters:
19+
xcodeVersion: 'Run_func_test_on_iOS'
20+
21+
- job: func_test_ios_webdriver1
22+
pool:
23+
vmImage: 'macOS-10.14'
24+
variables:
25+
CI: 'true'
26+
steps:
27+
- template: ./functional/ios_setup.yml
28+
parameters:
29+
xcodeVersion: 10.1
30+
- script: |
31+
bundle exec rake test:func:ios TEST=test/functional/ios/webdriver/create_session_test.rb;
32+
bundle exec rake test:func:ios TEST=test/functional/ios/webdriver/w3c_actions_test.rb
33+
displayName: Run tests
34+
- template: ./functional/publish_test_result.yml
35+
parameters:
36+
xcodeVersion: 'Run_func_test_on_iOS_webdriver1'
37+
38+
- job: func_test_ios_webdriver2
39+
pool:
40+
vmImage: 'macOS-10.14'
41+
variables:
42+
CI: 'true'
43+
steps:
44+
- template: ./functional/ios_setup.yml
45+
parameters:
46+
xcodeVersion: 10.1
47+
- script: |
48+
bundle exec rake test:func:ios TEST=test/functional/ios/webdriver/device_test.rb;
49+
displayName: Run tests
50+
- template: ./functional/publish_test_result.yml
51+
parameters:
52+
xcodeVersion: 'Run_func_test_on_iOS_webdriver2'
53+
54+
- job: func_test_ios_ios1
55+
pool:
56+
vmImage: 'macOS-10.14'
57+
variables:
58+
CI: 'true'
59+
steps:
60+
- template: ./functional/ios_setup.yml
61+
parameters:
62+
xcodeVersion: 10.1
63+
- script: |
64+
bundle exec rake test:func:ios TEST=test/functional/ios/ios/device_test.rb
65+
displayName: Run tests
66+
- template: ./functional/publish_test_result.yml
67+
parameters:
68+
xcodeVersion: 'Run_func_test_on_iOS_ios1'
69+
70+
- job: func_test_ios_ios2
71+
pool:
72+
vmImage: 'macOS-10.14'
73+
variables:
74+
CI: 'true'
75+
steps:
76+
- template: ./functional/ios_setup.yml
77+
parameters:
78+
xcodeVersion: 10.1
79+
- script: |
80+
bundle exec rake test:func:ios TEST=test/functional/ios/ios/device_wda_attachment_test.rb;
81+
bundle exec rake test:func:ios TEST=test/functional/ios/ios/image_comparison_test.rb
82+
displayName: Run tests
83+
- template: ./functional/publish_test_result.yml
84+
parameters:
85+
xcodeVersion: 'Run_func_test_on_iOS_ios2'
86+
87+
- job: func_test_ios_ios3
88+
pool:
89+
vmImage: 'macOS-10.14'
90+
variables:
91+
CI: 'true'
92+
steps:
93+
- template: ./functional/ios_setup.yml
94+
parameters:
95+
xcodeVersion: 10.1
96+
- script: |
97+
bundle exec rake test:func:ios TEST=test/functional/ios/ios/mjpeg_server_test.rb;
98+
bundle exec rake test:func:ios TEST=test/functional/ios/ios/mobile_commands_test.rb;
99+
bundle exec rake test:func:ios TEST=test/functional/ios/ios/search_context_test.rb
100+
displayName: Run tests
101+
- template: ./functional/publish_test_result.yml
102+
parameters:
103+
xcodeVersion: 'Run_func_test_on_iOS_ios3'
104+
105+
- job: func_test_ios_tvos
106+
pool:
107+
vmImage: 'macOS-10.14'
108+
variables:
109+
CI: 'true'
110+
steps:
111+
- template: ./functional/ios_setup.yml
112+
parameters:
113+
xcodeVersion: 10.2
114+
- script: |
115+
bundle exec rake test:func:ios TEST=test/functional/ios/tv_driver_test.rb
116+
displayName: Run tests
117+
- template: ./functional/publish_test_result.yml
118+
parameters:
119+
xcodeVersion: 'Run_func_test_on_iOS_tv'

test/functional/android/android/device_test.rb

-113
Original file line numberDiff line numberDiff line change
@@ -425,119 +425,6 @@ def test_file_management
425425
File.delete 'pic_folder.zip'
426426
end
427427

428-
def test_image_element
429-
skip 'Requires `npm install -g appium opencv4nodejs`' unless `npm list -g opencv4nodejs`.include? 'opencv4nodejs'
430-
431-
@driver.rotation = :portrait
432-
433-
el = @driver.find_element :accessibility_id, 'NFC'
434-
@driver.save_element_screenshot el, 'test/functional/data/test_android_nfc.png'
435-
436-
image_element = @driver.find_element_by_image AppiumLibCoreTest.path_of('test/functional/data/test_android_nfc.png')
437-
438-
assert image_element.inspect
439-
assert image_element.hash
440-
assert image_element.ref =~ /\Aappium-image-element-[a-z0-9\-]+/
441-
442-
el_location = el.location
443-
image_location = image_element.location
444-
assert_in_delta el_location.x, image_location.x, 1
445-
assert_in_delta el_location.y, image_location.y, 1
446-
447-
el_size = el.size
448-
image_size = image_element.size
449-
assert_in_delta el_size.width, image_size.width, 1
450-
assert_in_delta el_size.height, image_size.height, 1
451-
452-
el_rect = el.rect
453-
image_rect = image_element.rect
454-
assert_in_delta el_rect.x, image_rect.x, 1
455-
assert_in_delta el_rect.y, image_rect.y, 1
456-
assert_in_delta el_rect.width, image_rect.width, 1
457-
assert_in_delta el_rect.height, image_rect.height, 1
458-
459-
assert_equal el.displayed?, image_element.displayed?
460-
image_element.click
461-
462-
assert @driver.find_element :accessibility_id, 'TechFilter'
463-
@driver.back
464-
end
465-
466-
def test_image_elements
467-
skip 'Requires `npm install -g appium opencv4nodejs`' unless `npm list -g opencv4nodejs`.include? 'opencv4nodejs'
468-
469-
@driver.rotation = :landscape
470-
471-
el = @driver.find_element :accessibility_id, 'App'
472-
@driver.save_element_screenshot el, 'test/functional/data/test_android_app.png'
473-
474-
image_elements = @driver.find_elements_by_image AppiumLibCoreTest.path_of('test/functional/data/test_android_app.png')
475-
image_element = image_elements[0]
476-
477-
assert image_element.inspect
478-
assert image_element.hash
479-
assert image_element.ref =~ /\Aappium-image-element-[a-z0-9\-]+/
480-
481-
el_location = el.location
482-
image_location = image_element.location
483-
assert_in_delta el_location.x, image_location.x, 1
484-
assert_in_delta el_location.y, image_location.y, 1
485-
486-
el_size = el.size
487-
image_size = image_element.size
488-
assert_in_delta el_size.width, image_size.width, 1
489-
assert_in_delta el_size.height, image_size.height, 1
490-
491-
el_rect = el.rect
492-
image_rect = image_element.rect
493-
assert_in_delta el_rect.x, image_rect.x, 1
494-
assert_in_delta el_rect.y, image_rect.y, 1
495-
assert_in_delta el_rect.width, image_rect.width, 1
496-
assert_in_delta el_rect.height, image_rect.height, 1
497-
498-
assert_equal el.displayed?, image_element.displayed?
499-
image_element.click
500-
501-
assert @driver.find_element :accessibility_id, 'Action Bar'
502-
@driver.back
503-
end
504-
505-
def test_template_scale_ratio
506-
skip 'Requires `npm install -g appium opencv4nodejs`' unless `npm list -g opencv4nodejs`.include? 'opencv4nodejs'
507-
508-
@driver.rotation = :portrait
509-
510-
el = @driver.find_element :accessibility_id, 'NFC'
511-
@driver.save_element_screenshot el, 'test/functional/data/test_android_nfc.png'
512-
513-
@driver.update_settings({ defaultImageTemplateScale: 4 })
514-
515-
image_element = @driver.find_element_by_image AppiumLibCoreTest.path_of('test/functional/data/test_android_nfc_270.png')
516-
assert image_element.inspect
517-
assert image_element.hash
518-
assert image_element.ref =~ /\Aappium-image-element-[a-z0-9\-]+/
519-
520-
el_location = el.location
521-
image_location = image_element.location
522-
assert_in_delta el_location.x, image_location.x, 3
523-
assert_in_delta el_location.y, image_location.y, 3
524-
525-
el_size = el.size
526-
image_size = image_element.size
527-
assert_in_delta el_size.width, image_size.width, 3
528-
assert_in_delta el_size.height, image_size.height, 3
529-
530-
el_rect = el.rect
531-
image_rect = image_element.rect
532-
assert_in_delta el_rect.x, image_rect.x, 3
533-
assert_in_delta el_rect.y, image_rect.y, 3
534-
assert_in_delta el_rect.width, image_rect.width, 3
535-
assert_in_delta el_rect.height, image_rect.height, 3
536-
537-
assert_equal el.displayed?, image_element.displayed?
538-
image_element.click
539-
end
540-
541428
private
542429

543430
def scroll_to(text)

0 commit comments

Comments
 (0)