xcmonkey 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bf6aac9a0ce5cf477ad675ca689b4120411e39a19b3b5cd7647b47dea04db9c1
4
- data.tar.gz: fb564d25a9085e5bb9fdfa277a877278ab8055c502699f3a2b9430280a035046
3
+ metadata.gz: 7a6aa190c1c4cfa28f97b20524c907da488aad2d78f2c1dda8f827899f6ee53f
4
+ data.tar.gz: 534245a695ed0f030df459986c326fb356b3593baec3bc6750eb1cc622d32390
5
5
  SHA512:
6
- metadata.gz: d25221ebda9c465da1f09740b10779fd4f4a12886d2c5b87c4096eeb9c3ef3076180e3365140ce8d5ff28afc6709445efae4b7ec8b9fdbae2317d8f4cf5a9ba1
7
- data.tar.gz: d186b5ead7789373d0a3da5edb8ea11f4f2518e4fdd766c27a79adf315b830cfd95ae3f381543c55b02ba0f3da6ab3431394adcb99949d26b97dcda719de7eee
6
+ metadata.gz: 41415c8c576a3b6887ee87d44f4c4e571f1e7abda3a96f23abff52cebe77438be70ee76ab18f83a92b78cca2da429cf0c12305b2d3a8ca59b0b2e7e26405ec23
7
+ data.tar.gz: 93d86451b2b7b8d2a755744ea47be375d042763ea550ddbdef5faff530bbf775e46ab24ede0f6d9dfe424f02ef4c2a923ccd3f342d1872cd6f4d82dcefae7cef
data/.github/FUNDING.yml CHANGED
@@ -1,5 +1,3 @@
1
- # These are supported funding model platforms
2
-
1
+ custom: [ 'https://revolut.me/alteral', 'https://paypal.me/aapesotskiy' ]
3
2
  github: alteral
4
3
  ko_fi: alteral
5
- custom: [ 'https://revolut.me/alteral', 'https://paypal.me/aapesotskiy' ]
@@ -0,0 +1,38 @@
1
+ name: Test
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+ - develop
8
+
9
+ pull_request:
10
+ types: [opened, synchronize]
11
+
12
+ jobs:
13
+ chat:
14
+ name: Automated Code Review
15
+ runs-on: macos-12
16
+ timeout-minutes: 15
17
+ env:
18
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
19
+ SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
20
+ steps:
21
+ - uses: actions/checkout@v3.2.0
22
+
23
+ - uses: actions/setup-python@v4.4.0
24
+ with:
25
+ python-version: 3.11
26
+ cache: 'pip'
27
+
28
+ - run: bundle install
29
+
30
+ - run: brew install sonar-scanner
31
+
32
+ - run: brew install facebook/fb/idb-companion
33
+
34
+ - run: pip install -r requirements.txt
35
+
36
+ - run: bundle exec fastlane code_review
37
+
38
+ - run: bundle exec fastlane sonar_upload
data/README.md CHANGED
@@ -1,19 +1,24 @@
1
- *xcmonkey* is a tool for doing randomised UI testing of iOS apps 🐒
1
+ <p align="center">
2
+ <img src="/assets/images/xcmonkey.png"/>
3
+ </p>
2
4
 
3
- ## Requirements
5
+ <p align="center">
6
+ <a href="https://github.com/alteral/xcmonkey/actions"><img src="https://github.com/alteral/xcmonkey/actions/workflows/test.yml/badge.svg" /></a>
7
+ <a href="https://sonarcloud.io/summary/new_code?id=alteral_xcmonkey"><img src="https://sonarcloud.io/api/project_badges/measure?project=alteral_xcmonkey&metric=coverage" /></a>
8
+ <a href="https://rubygems.org/gems/xcmonkey"><img src="https://img.shields.io/gem/v/xcmonkey.svg?style=flat" /></a>
9
+ <a href="/LICENSE"><img src="https://img.shields.io/badge/license-MIT-green.svg?style=flat" /></a>
10
+ </p>
4
11
 
5
- ```bash
6
- brew tap facebook/fb
7
- brew install idb-companion
8
- ```
12
+ *xcmonkey* is a tool for doing randomised UI testing of iOS apps.
9
13
 
10
- ## Installation
14
+ ## Requirements
11
15
 
12
16
  ```bash
13
- brew install xcmonkey
17
+ brew install facebook/fb/idb-companion
18
+ pip3.6 install fb-idb
14
19
  ```
15
20
 
16
- or
21
+ ## Installation
17
22
 
18
23
  ```bash
19
24
  gem install xcmonkey
@@ -24,13 +29,61 @@ gem install xcmonkey
24
29
  ### Test
25
30
 
26
31
  ```bash
27
- xcmonkey test --udid "30694803-2018-460F-BBA6-97D7911A1AC0" --bundle-id "com.example.app"
32
+ $ xcmonkey test --udid "413EA256-CFFB-4312-94A6-12592BEE4CBA" --bundle-id "com.apple.mobilesafari"
33
+ 12:44:19.343: Device info: iPhone 14 Pro | 413EA256-CFFB-4312-94A6-12592BEE4CBA | Booted | simulator | iOS 16.2 | x86_64 | /tmp/idb/413EA256-CFFB-4312-94A6-12592BEE4CBA_companion.sock
34
+
35
+ 12:44:22.550: App info: com.apple.mobilesafari | MobileSafari | system | x86_64, arm64 | Running | Not Debuggable | pid=43398
36
+
37
+ 12:44:23.203: Tap: {
38
+ "x": 53,
39
+ "y": 749
40
+ }
41
+
42
+ 12:44:23.511: Swipe: {
43
+ "x": 196,
44
+ "y": 426
45
+ } => {
46
+ "x": 143,
47
+ "y": 447
48
+ }
49
+
50
+ 12:44:24.355: Tap: {
51
+ "x": 143,
52
+ "y": 323
53
+ }
28
54
  ```
29
55
 
30
56
  ### Describe point
31
57
 
32
58
  ```bash
33
- xcmonkey describe -x 10 -y 10 --udid "20694801-2018-460F-BBA6-97D7911A1AC0"
59
+ $ xcmonkey describe -x 125 -y 760 --udid "413EA256-CFFB-4312-94A6-12592BEE4CBA"
60
+ 12:41:03.840: Device info: iPhone 14 Pro | 413EA256-CFFB-4312-94A6-12592BEE4CBA | Booted | simulator | iOS 16.2 | x86_64 | /tmp/idb/413EA256-CFFB-4312-94A6-12592BEE4CBA_companion.sock
61
+
62
+ 12:41:05.342: x:125 y:760 point info: {
63
+ "AXFrame": "{{120, 759}, {64, 64}}",
64
+ "AXUniqueId": "Safari",
65
+ "frame": {
66
+ "y": 759,
67
+ "x": 120,
68
+ "width": 64,
69
+ "height": 64
70
+ },
71
+ "role_description": "button",
72
+ "AXLabel": "Safari",
73
+ "content_required": false,
74
+ "type": "Button",
75
+ "title": null,
76
+ "help": "Double tap to open",
77
+ "custom_actions": [
78
+ "Edit mode",
79
+ "Today",
80
+ "App Library"
81
+ ],
82
+ "AXValue": "",
83
+ "enabled": true,
84
+ "role": "AXButton",
85
+ "subrole": null
86
+ }
34
87
  ```
35
88
 
36
89
  ## Code of Conduct
Binary file
data/fastlane/Fastfile CHANGED
@@ -20,6 +20,34 @@ lane :code_review do
20
20
  sh('bundle exec rake')
21
21
  end
22
22
 
23
+ lane :sonar_upload do
24
+ update_simplecov_report
25
+ sonar_options =
26
+ if ENV['GITHUB_EVENT_NAME'] == 'pull_request'
27
+ {
28
+ sonar_login: ENV.fetch('SONAR_TOKEN', nil),
29
+ pull_request_branch: ENV.fetch('GITHUB_HEAD_REF', nil),
30
+ pull_request_base: ENV.fetch('GITHUB_BASE_REF', nil),
31
+ pull_request_key: ENV.fetch('PR_NUMBER', nil)
32
+ }
33
+ else
34
+ {
35
+ sonar_login: ENV.fetch('SONAR_TOKEN', nil),
36
+ branch_name: ENV['BRANCH_NAME'] || git_branch,
37
+ project_version: version
38
+ }
39
+ end
40
+
41
+ sonar(sonar_options)
42
+ end
43
+
44
+ private_lane :update_simplecov_report do
45
+ coverage = JSON.parse(File.read('../coverage/.resultset.json'))["RSpec"]["coverage"]
46
+ transformed_values = coverage.transform_values { |l| l["lines"] }
47
+ new_format = { "RSpec" => { "coverage" => transformed_values, "timestamp" => Time.now.to_i } }
48
+ File.write('../coverage/.sonar.json', JSON.pretty_generate(new_format))
49
+ end
50
+
23
51
  def version
24
52
  version_path = '../lib/xcmonkey/version.rb'
25
53
  File.read(version_path).scan(/\d+/).join('.')
@@ -23,6 +23,8 @@ class Driver
23
23
  tap(coordinates: { x: x, y: y })
24
24
  when :swipe
25
25
  swipe(start_coordinates: el1_coordinates, end_coordinates: el2_coordinates)
26
+ else
27
+ next
26
28
  end
27
29
  app_elements = describe_ui.shuffle
28
30
  Logger.error('App lost') if app_elements.include?(@home_tracker)
@@ -46,6 +48,7 @@ class Driver
46
48
 
47
49
  def launch_app
48
50
  `idb launch --udid #{udid} #{bundle_id}`
51
+ wait_until_app_launched
49
52
  end
50
53
 
51
54
  def terminate_app
@@ -122,4 +125,16 @@ class Driver
122
125
  end
123
126
  @home_tracker
124
127
  end
128
+
129
+ def wait_until_app_launched
130
+ app_info = nil
131
+ current_time = Time.now
132
+ while app_info.nil? && Time.now < current_time + 5
133
+ app_info = list_apps.split("\n").detect do |app|
134
+ app =~ /#{bundle_id}.*Running/
135
+ end
136
+ end
137
+ Logger.error("Can't run the app #{bundle_id}") if app_info.nil?
138
+ Logger.info('App info:', payload: app_info)
139
+ end
125
140
  end
@@ -1,4 +1,4 @@
1
1
  module Xcmonkey
2
- VERSION = '0.1.1'
2
+ VERSION = '0.1.2'
3
3
  GEM_NAME = 'xcmonkey'
4
4
  end
data/requirements.txt ADDED
@@ -0,0 +1 @@
1
+ fb-idb
@@ -0,0 +1,11 @@
1
+ sonar.projectKey=alteral_xcmonkey
2
+ sonar.projectName=xcmonkey
3
+ sonar.host.url=https://sonarcloud.io
4
+ sonar.organization=alteral
5
+ sonar.ruby.coverage.reportPaths=coverage/.sonar.json
6
+ sonar.ruby.coverage.framework=RSpec
7
+ sonar.sources=lib/
8
+ sonar.inclusions=lib/**/*.rb
9
+ sonar.exclusions=lib/**/version.rb
10
+ sonar.tests=spec/
11
+ sonar.test.inclusions=spec/*_spec.rb
data/spec/driver_spec.rb CHANGED
@@ -85,6 +85,14 @@ describe Driver do
85
85
  expect(actual_coordinates).to eq(expected_coordinates)
86
86
  end
87
87
 
88
+ it 'verifies that app can be launched' do
89
+ expect(Logger).not_to receive(:error)
90
+ expect(Logger).to receive(:info)
91
+ driver.boot_simulator
92
+ driver.terminate_app
93
+ expect { driver.launch_app }.not_to raise_error
94
+ end
95
+
88
96
  it 'verifies that simulator was not booted' do
89
97
  driver.shutdown_simulator
90
98
  error_message = "Failed to boot #{udid}"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xcmonkey
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - alteral
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-12-27 00:00:00.000000000 Z
11
+ date: 2022-12-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -218,7 +218,7 @@ files:
218
218
  - ".github/FUNDING.yml"
219
219
  - ".github/dependabot.yml"
220
220
  - ".github/pull_request_template.md"
221
- - ".github/workflows/Test.yml"
221
+ - ".github/workflows/test.yml"
222
222
  - ".gitignore"
223
223
  - ".rspec"
224
224
  - ".rubocop.yml"
@@ -227,6 +227,7 @@ files:
227
227
  - LICENSE
228
228
  - README.md
229
229
  - Rakefile
230
+ - assets/images/xcmonkey.png
230
231
  - bin/console
231
232
  - bin/setup
232
233
  - bin/xcmonkey
@@ -236,6 +237,8 @@ files:
236
237
  - lib/xcmonkey/driver.rb
237
238
  - lib/xcmonkey/logger.rb
238
239
  - lib/xcmonkey/version.rb
240
+ - requirements.txt
241
+ - sonar-project.properties
239
242
  - spec/describer_spec.rb
240
243
  - spec/driver_spec.rb
241
244
  - spec/logger_spec.rb
@@ -1,29 +0,0 @@
1
- name: Test
2
-
3
- on:
4
- pull_request:
5
- types: [opened, synchronize]
6
-
7
- jobs:
8
- chat:
9
- name: Checks
10
- timeout-minutes: 15
11
- runs-on: macos-12
12
- steps:
13
- - uses: actions/checkout@v3.1.0
14
- with:
15
- fetch-depth: '0'
16
- - uses: actions/cache@v3
17
- id: bundler-cache
18
- with:
19
- path: vendor/bundle
20
- key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}
21
- restore-keys: |
22
- ${{ runner.os }}-gems-
23
- - name: Bundler
24
- run: |
25
- gem install bundler
26
- bundle config path vendor/bundle
27
- bundle check || bundle install --jobs 4 --retry 3
28
- - name: Rubocop
29
- run: bundle exec rake