smart_monkey 0.1.2 → 0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0f738b9ed13db8b304d0294e755569da6085a99f
4
- data.tar.gz: 43029b8fefa454d818e2ad4b3e9a52cc0e8923e9
3
+ metadata.gz: 654c78960662ad050551e259c70eb156943f1a5b
4
+ data.tar.gz: e9d4cd8bf1d0352594231fd885cb869877ad534d
5
5
  SHA512:
6
- metadata.gz: dadfa51c02979055e92c8ae6620e1dd47b3ce008d547b86ef50b4429339c27558dad499a782b0d351a46dc11039b48e6239a78b0577497c0a99120665074759a
7
- data.tar.gz: 9c94e9632a44b457c851b8760b5e53af82af01188deb863969ffe11fcebfe7af7a3c39abdd230ee548f843828c4700bf7a815df8aa613453197800d1070a746d
6
+ metadata.gz: a1cf9150d136402f4381625ad51370f46dc0b8d958b5a2f9bfbf025f370e22805a9a53eb0a7de9d61b3490470e30e6df01a6be37870ac2f52d087e014a7e6362
7
+ data.tar.gz: 566dc5f0252c36409c7dbcc88278f59b3501e74232c75daafae59e6d571902303309ffcd75a28ed9c53519971f75afd8a9ab959ccbc44478ea9e398d71680152
data/README.md CHANGED
@@ -1,18 +1,15 @@
1
1
  # CrashMonkey4IOS
2
2
  iOS Monkey Test Tool.
3
3
 
4
- ###改进点:
5
- 1. 原先的CrashMonkey只支持iPhone Simulator测试,修改后**支持真机测试**(目前模拟器的兼容没有做)
6
- 2. 支持真机收集**系统日志(Systemlog)**,利用[deviceconsole][dc]实现
7
- 3. 支持真机收集**崩溃日志(Crashlog)**,利用[libimobiledevice][lidvc]的**idevicecrashreport**实现
8
- 4. 解决在iPhone5及以上分辨率的设备上测试报告截图手势坐标绘制错误的问题
9
- 5. 解决判定crash出现失败的情况。
10
- 6. 测试报告中添加设备信息及应用信息(Summary下)
11
- 7. 使用最新版的[UIAutoMonkey][uiatmonkey],加入`UI Holes`与`Application Not Repsonding ("ANR")`的处理,添加[custom.js][custom]作为入口脚本.
12
- 8. 加入[tuneup][tp]依赖
13
- 9. 修改**UIAutoMonkey.js**中截图策略,为每个Event Action进行截图
14
- 10. 修改**CrashMonkey**中测试报告显示截图策略,增加至最近的50张
15
- 11. 解决大家一直所诟病的iOS App执行Monkey测试过程当中跳出程序后,导致脚本block,App无法自动返回的问题,解决方案:利用一个线程去监听instruments执行过程当中的日志,每隔20s进行前后比对,如果日志没有更新则说明App hanged,利用**idevicedebug**恢复App至前台。
4
+ ###简要说明:
5
+ 1. 支持**真机测试、模拟器测试**
6
+ 2. 支持收集**系统日志(Systemlog)**、**崩溃日志(Crashlog)**、***instrument行为日志***
7
+ 3. 支持测试报告截图,绘制行为轨迹
8
+ 4. 支持测试设备信息收集
9
+ 5. 使用最新版的[UIAutoMonkey][uiatmonkey],加入`UI Holes`与`Application Not Repsonding ("ANR")`的处理,添加[custom.js][custom]作为入口脚本.
10
+ 6. 加入[tuneup][tp]依赖
11
+ 7. 修改**UIAutoMonkey.js**中截图策略,为每个Event Action进行截图
12
+ 8. 支持测试执行过程中App进入后台,自动恢复(测试不会block)
16
13
  [lidvc]:https://github.com/libimobiledevice/libimobiledevice
17
14
  [dc]:https://github.com/rpetrich/deviceconsole
18
15
  [uiatmonkey]: https://github.com/jonathanpenn/ui-auto-monkey/blob/master/UIAutoMonkey.js
@@ -20,24 +17,32 @@ iOS Monkey Test Tool.
20
17
  [tp]:https://github.com/vigossjjj/CrashMonkey4IOS/tree/master/lib/ui-auto-monkey/tuneup
21
18
  [troubleshooting]:https://github.com/vigossjjj/CrashMonkey4IOS/tree/master/Troubleshooting.md
22
19
 
23
- ###依赖及安装:
20
+ ###环境及依赖安装:
21
+ ###### 系统要求
24
22
  1. 安装Ruby运行环境,建议不要使用OS X自带版本,可自行使用RVM安装最新版的Ruby。建议使用淘宝镜像安装,速度比较快,`$ sed -i -e 's/ftp\.ruby-lang\.org\/pub\/ruby/ruby\.taobao\.org\/mirrors\/ruby/g' ~/.rvm/config/db`
25
23
  2. 确保gem可用,也建议使用淘宝镜像 `gem sources --remove https://rubygems.org/;gem sources -a http://ruby.taobao.org/;gem sources -l`
26
24
  3. 安装**Homebrew** `ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"`
25
+ 4. 建议Xcode 6.x +
26
+
27
+ ###### 依赖安装
28
+ 1. `brew install -HEAD ideviceinstaller`
29
+ 2. `brew install libimobiledevice`
30
+ 3. `brew install imagemagick`
31
+ 4. `gem install smart_monkey`
27
32
 
28
33
  ###使用说明:
29
- 1. 运行`sh reset.sh`安装相关依赖
30
- 2. 执行前需要先配置[custom.js][custom]相关参数
31
- 3. 执行命令`/CrashMonkey4IOS/bin/smart_monkey -a ${App_BunnelID} -w ${iPhone_UDID} -n 1`
34
+ 1. 执行前需要先配置[custom.js][custom]相关参数
35
+ 2. 执行命令`smart_monkey -a ${App_BunnelID} -w ${iPhone_UDID}`
32
36
 
33
37
  ###参数说明:
34
38
  ```
39
+ $ smart_monkey -h
35
40
  Usage: smart_monkey [options]
36
- -a app_name Target Application, abs path to simulator-compiled .app file or the bundle_id of the desired target on device(Required)
41
+ -a app_name Bundle ID of the desired target on device(Required)
37
42
  -w device Target Device UDID(Required)
38
43
  -n run_count How many times monkeys run(default: 1)
39
44
  -d result_dir Where to output result(default: ./smart_monkey_result)
40
- -t time_limit_sec Time limit of running(default: 100 sec)
45
+ -t time_limit_sec Time limit of running
41
46
  -s dsym_file Use .dSYM file to symbolicating crash logs
42
47
  -c custom_path Configuration custom.js Path
43
48
  -e extend_javascript_path Extend Uiautomation Javascript for such Login scripts
@@ -50,12 +55,11 @@ Usage: smart_monkey [options]
50
55
  --list-app Show List of Installed Apps in iPhone/iPhone Simulator
51
56
  --list-devices Show List of Devices
52
57
  --reset-iPhone-Simulator Reset iPhone Simulator
53
- --version print crash monkey version
58
+ --version print smart monkey version
54
59
  ```
55
60
 
56
61
  ###TODO List:
57
- 1. 适配iPhone Simulator
58
- 2. 修改配置脚本及文档。
62
+ 2. 配置文件参数优化
59
63
 
60
64
  ###Troubleshooting:
61
65
  安装和执行测试遇到的问题解决方案请参看:[Troubleshooting.md][troubleshooting]
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.2
1
+ 0.2
data/bin/smart_monkey CHANGED
@@ -11,11 +11,11 @@ require 'smart_monkey'
11
11
 
12
12
  opts = {}
13
13
  ARGV.options do |o|
14
- o.on('-a app_name', 'Target Application, abs path to simulator-compiled .app file or the bundle_id of the desired target on device(Required)') {|b| opts[:app_path] = b}
14
+ o.on('-a app_name', 'Bundle ID of the desired target on device(Required)') {|b| opts[:app_path] = b}
15
15
  o.on('-w device', 'Target Device UDID(Required)') {|b| opts[:device] = b}
16
16
  o.on('-n run_count', 'How many times monkeys run(default: 1)') {|b| opts[:run_count] = b.to_i}
17
17
  o.on('-d result_dir', 'Where to output result(default: ./smart_monkey_result)') {|b| opts[:result_base_dir] = File.expand_path(b)}
18
- o.on('-t time_limit_sec', 'Time limit of running(default: 100 sec)') {|b| opts[:time_limit_sec] = b.to_i}
18
+ o.on('-t time_limit_sec', 'Time limit of running') {|b| opts[:time_limit_sec] = b.to_i}
19
19
  o.on('-s dsym_file', 'Use .dSYM file to symbolicating crash logs') {|b| opts[:dsym_file_path] = File.expand_path(b)}
20
20
  o.on('-c custom_path', 'Configuration custom.js Path') {|b| opts[:custom_path] = File.expand_path(b)}
21
21
  o.on('-e extend_javascript_path', 'Extend Uiautomation Javascript for such Login scripts') {|b| opts[:extend_javascript_path] = File.expand_path(b)}
@@ -26,7 +26,7 @@ ARGV.options do |o|
26
26
  o.on('--list-app', 'Show List of Installed Apps in iPhone/iPhone Simulator') {|_| opts[:list_app] = true}
27
27
  o.on('--list-devices', 'Show List of Devices') {|_| opts[:list_devices] = true}
28
28
  o.on('--reset-iPhone-Simulator', 'Reset iPhone Simulator'){|_| opts[:reset_iphone_simulator] = true}
29
- o.on('--version', 'print crash monkey version'){|_| opts[:version] = true}
29
+ o.on('--version', 'print smart monkey version'){|_| opts[:version] = true}
30
30
  o.parse!
31
31
  end
32
32
 
@@ -17,11 +17,6 @@ module UIAutoMonkey
17
17
 
18
18
  def run(opts)
19
19
  @options = opts
20
- res_dir = @options[:result_base_dir] || RESULT_BASE_PATH
21
-
22
- puts "INSTRUMENTS_TRACE_PATH : #{INSTRUMENTS_TRACE_PATH}"
23
- puts "RESULT_BASE_PATH : #{res_dir}"
24
-
25
20
  if @options[:show_config]
26
21
  show_config
27
22
  return true
@@ -35,6 +30,11 @@ module UIAutoMonkey
35
30
  reset_iphone_simulator
36
31
  return true
37
32
  end
33
+
34
+ res_dir = @options[:result_base_dir] || RESULT_BASE_PATH
35
+ puts "INSTRUMENTS_TRACE_PATH : #{INSTRUMENTS_TRACE_PATH}"
36
+ puts "RESULT_BASE_PATH : #{res_dir}"
37
+
38
38
  ###########
39
39
  log @options.inspect
40
40
  FileUtils.remove_dir(result_base_dir, true)
@@ -76,7 +76,7 @@ module UIAutoMonkey
76
76
  def run_a_case
77
77
  log "=================================== Start Test (#{@times+1}/#{total_test_count}) ======================================="
78
78
  FileUtils.makedirs(crash_save_dir(@times+1)) unless File.exists?(crash_save_dir(@times+1))
79
- pull_crash_from_iphone(@times+1)
79
+ pull_crash_files(@times+1)
80
80
  cr_list = crash_report_list(@times+1)
81
81
  start_time = Time.now
82
82
  watch_syslog do
@@ -91,7 +91,7 @@ module UIAutoMonkey
91
91
  end
92
92
  end
93
93
 
94
- pull_crash_from_iphone(@times+1)
94
+ pull_crash_files(@times+1)
95
95
  new_cr_list = crash_report_list(@times+1)
96
96
  # increase crash report?
97
97
  diff_cr_list = new_cr_list - cr_list
@@ -212,6 +212,19 @@ module UIAutoMonkey
212
212
  `"instruments" -s devices`.strip.split(/\n/).drop(2)
213
213
  end
214
214
 
215
+ def instruments_deviceinfo(device)
216
+ `"instruments" -s devices | grep #{device}`.strip
217
+ end
218
+
219
+ def is_simulator
220
+ deviceinfo = instruments_deviceinfo(device)
221
+ if deviceinfo.include? "Simulator"
222
+ true
223
+ else
224
+ false
225
+ end
226
+ end
227
+
215
228
  def product_type(device)
216
229
  product_hash={
217
230
  "iPhone7,2"=>"iPhone 6",
@@ -229,16 +242,25 @@ module UIAutoMonkey
229
242
  "iPhone1,2"=>"iPhone 3G",
230
243
  "iPhone1,1"=>"iPhone",
231
244
  }
232
- type=`ideviceinfo -u #{device} -k ProductType`.strip
233
- product_hash[type]
245
+
246
+ if is_simulator
247
+ instruments_deviceinfo(device).split("[")[0]
248
+ else
249
+ type = `ideviceinfo -u #{device} -k ProductType`.strip
250
+ product_hash[type]
251
+ end
234
252
  end
235
253
 
236
254
  def product_version(device)
237
- `ideviceinfo -u #{device} -k ProductVersion`.strip
255
+ if !is_simulator
256
+ `ideviceinfo -u #{device} -k ProductVersion`.strip
257
+ end
238
258
  end
239
259
 
240
260
  def device_name(device)
241
- `ideviceinfo -u #{device} -k DeviceName`.strip
261
+ if !is_simulator
262
+ `ideviceinfo -u #{device} -k DeviceName`.strip
263
+ end
242
264
  end
243
265
 
244
266
  def compress_image(path)
@@ -345,12 +367,16 @@ module UIAutoMonkey
345
367
  "#{result_base_dir}/result_#{sprintf('%03d', times)}"
346
368
  end
347
369
 
348
- def crash_report_dir
370
+ def sim_crash_report_dir
349
371
  "#{ENV['HOME']}/Library/Logs/DiagnosticReports"
350
372
  end
351
373
 
352
- def pull_crash_from_iphone(times)
353
- `idevicecrashreport -u #{device} -e -k #{crash_save_dir(times)}`
374
+ def pull_crash_files(times)
375
+ if !is_simulator
376
+ `idevicecrashreport -u #{device} -e -k #{crash_save_dir(times)}`
377
+ else
378
+ `cp #{sim_crash_report_dir}/* #{crash_save_dir(times)}`
379
+ end
354
380
  end
355
381
 
356
382
  def crash_report_list(times)
@@ -363,12 +389,14 @@ module UIAutoMonkey
363
389
  `rm -rf #{traces}`
364
390
  end
365
391
 
366
- def grep_syslog
367
- 'tail -n 0 -f /var/log/system.log'
368
- end
369
-
370
392
  def grep_ios_syslog
371
- "#{deviceconsole_original_path} -u #{device}"
393
+ if is_simulator
394
+ puts "Attempting iOS Simulator system log capture via tail system.log."
395
+ "tail -n 0 -f ~/Library/Logs/CoreSimulator/#{device}*/system.log"
396
+ else
397
+ puts "Attempting iOS device system log capture via deviceconsole."
398
+ "#{deviceconsole_original_path} -u #{device}"
399
+ end
372
400
  end
373
401
 
374
402
  def console_log_path
@@ -460,7 +488,6 @@ module UIAutoMonkey
460
488
 
461
489
  def watch_syslog
462
490
  STDOUT.sync = true
463
- puts "Attempting iOS device system log capture via deviceconsole."
464
491
  stdin, stdout, stderr = Open3.popen3(grep_ios_syslog)
465
492
  log_filename = "#{result_base_dir}/console.txt"
466
493
  thread = Thread.new do
@@ -12,7 +12,7 @@
12
12
  <h1>Summary</h1>
13
13
  <div>
14
14
  <ul>
15
- <li>Hardware: <%= ProductType %>, <%= ProductVersion %>, <%= UniqueDeviceID %></li>
15
+ <li>Hardware: <%= ProductType %> <%= ProductVersion %> <%= UniqueDeviceID %></li>
16
16
  <li>Application: <%= Application %> </li>
17
17
  <li>Span: <%= start_time %> ~ <%= end_time %></li>
18
18
  <li>Results: <%= test_count %> Test, <%= ok_count %> Ok, <%= cr_count %> Crash, <%= nr_count %> No Run</li>
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smart_monkey
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: '0.2'
5
5
  platform: ruby
6
6
  authors:
7
7
  - vigossjjj