rubotium 0.0.4 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +4 -0
- data/bin/rubotium +4 -2
- data/lib/rubotium/adb/commands/command.rb +55 -0
- data/lib/rubotium/adb/commands/install_command.rb +19 -0
- data/lib/rubotium/adb/commands/instrument_command.rb +27 -0
- data/lib/rubotium/adb/commands/memory_command.rb +19 -0
- data/lib/rubotium/adb/commands/pull_command.rb +19 -0
- data/lib/rubotium/adb/commands/shell_command.rb +21 -0
- data/lib/rubotium/adb/commands/uninstall_command.rb +19 -0
- data/lib/rubotium/adb/commands.rb +7 -0
- data/lib/rubotium/adb/devices.rb +15 -6
- data/lib/rubotium/adb/parsers/procrank.rb +51 -0
- data/lib/rubotium/adb/parsers/single_test_result_parser.rb +61 -0
- data/lib/rubotium/adb/parsers/test_results_parser.rb +69 -0
- data/lib/rubotium/adb/parsers.rb +3 -0
- data/lib/rubotium/adb/test_result_parser.rb +5 -4
- data/lib/rubotium/adb.rb +3 -5
- data/lib/rubotium/apk/android_apk.rb +102 -0
- data/lib/rubotium/apk.rb +2 -2
- data/lib/rubotium/cmd.rb +1 -1
- data/lib/rubotium/device.rb +19 -33
- data/lib/rubotium/devices.rb +27 -14
- data/lib/rubotium/formatters/junit_formatter.rb +10 -11
- data/lib/rubotium/memory/data_point.rb +63 -0
- data/lib/rubotium/memory/monitor.rb +65 -0
- data/lib/rubotium/memory.rb +8 -0
- data/lib/rubotium/package.rb +7 -4
- data/lib/rubotium/runnable_test.rb +13 -0
- data/lib/rubotium/test_cases_reader.rb +32 -0
- data/lib/rubotium/test_result.rb +52 -0
- data/lib/rubotium/test_results.rb +18 -0
- data/lib/rubotium/test_runners/instrumentation_test_runner.rb +24 -0
- data/lib/rubotium/tests_runner.rb +80 -0
- data/lib/rubotium/version.rb +1 -1
- data/lib/rubotium.rb +54 -41
- data/rubotium.gemspec +0 -1
- data/spec/fixtures/adb_raw_result.rb +138 -0
- data/spec/fixtures/adb_raw_results.rb +153 -0
- data/spec/fixtures/adb_results.rb +4 -0
- data/spec/lib/rubotium/adb/adb_devices_spec.rb +43 -12
- data/spec/lib/rubotium/adb/adb_result_parser_spec.rb +22 -7
- data/spec/lib/rubotium/adb/adb_shell_spec.rb +11 -6
- data/spec/lib/rubotium/adb/parsers/procrank_spec.rb +61 -0
- data/spec/lib/rubotium/adb/parsers/single_test_result_parser_spec.rb +116 -0
- data/spec/lib/rubotium/adb/parsers/test_results_parser_spec.rb +108 -0
- data/spec/lib/rubotium/apk/android_apk_spec.rb +37 -0
- data/spec/lib/rubotium/apk/mock/BarcodeScanner4.2.apk +0 -0
- data/spec/lib/rubotium/apk/mock/UECExpress.apk +0 -0
- data/spec/lib/rubotium/apk/mock/dummy.apk +1 -0
- data/spec/lib/rubotium/apk/mock/sample.apk +0 -0
- data/spec/lib/rubotium/device_spec.rb +38 -0
- data/spec/lib/rubotium/devices_spec.rb +41 -24
- data/spec/lib/rubotium/memory/data_point_spec.rb +42 -0
- data/spec/lib/rubotium/memory/monitor_spec.rb +6 -0
- data/spec/lib/rubotium/tests_runner_spec.rb +47 -0
- data/spec/spec_helper.rb +2 -0
- data/test.rb +11 -0
- metadata +62 -41
- data/lib/rubotium/adb/command.rb +0 -21
- data/lib/rubotium/adb/install_command.rb +0 -17
- data/lib/rubotium/adb/instrumentation.rb +0 -36
- data/lib/rubotium/adb/uninstall_command.rb +0 -17
- data/lib/rubotium/apk/converter.rb +0 -22
- data/lib/rubotium/grouper.rb +0 -40
- data/lib/rubotium/jar_reader.rb +0 -70
- data/lib/rubotium/runable_test.rb +0 -11
- data/lib/rubotium/test_case.rb +0 -6
- data/lib/rubotium/test_suite.rb +0 -12
- data/spec/lib/rubotium/adb/adb_instrumentation_spec.rb +0 -32
- data/spec/lib/rubotium/grouper_spec.rb +0 -56
- data/spec/lib/rubotium/jar_reader_spec.rb +0 -58
metadata
CHANGED
@@ -1,27 +1,27 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubotium
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Slawomir Smiechura
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-10-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ~>
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '1.5'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ~>
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.5'
|
27
27
|
- !ruby/object:Gem::Dependency
|
@@ -70,28 +70,28 @@ dependencies:
|
|
70
70
|
name: rspec-mocks
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- -
|
73
|
+
- - '>='
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '0'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- -
|
80
|
+
- - '>='
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: rake
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- -
|
87
|
+
- - '>='
|
88
88
|
- !ruby/object:Gem::Version
|
89
89
|
version: '0'
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- -
|
94
|
+
- - '>='
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
97
|
- !ruby/object:Gem::Dependency
|
@@ -150,20 +150,6 @@ dependencies:
|
|
150
150
|
- - '='
|
151
151
|
- !ruby/object:Gem::Version
|
152
152
|
version: 0.0.6
|
153
|
-
- !ruby/object:Gem::Dependency
|
154
|
-
name: android_apk
|
155
|
-
requirement: !ruby/object:Gem::Requirement
|
156
|
-
requirements:
|
157
|
-
- - '='
|
158
|
-
- !ruby/object:Gem::Version
|
159
|
-
version: 0.7.0
|
160
|
-
type: :runtime
|
161
|
-
prerelease: false
|
162
|
-
version_requirements: !ruby/object:Gem::Requirement
|
163
|
-
requirements:
|
164
|
-
- - '='
|
165
|
-
- !ruby/object:Gem::Version
|
166
|
-
version: 0.7.0
|
167
153
|
description: This gem allows to run Robotium tests in parallel on multiple devices
|
168
154
|
email:
|
169
155
|
- ssmiech@gmail.com
|
@@ -172,7 +158,7 @@ executables:
|
|
172
158
|
extensions: []
|
173
159
|
extra_rdoc_files: []
|
174
160
|
files:
|
175
|
-
-
|
161
|
+
- .gitignore
|
176
162
|
- Gemfile
|
177
163
|
- LICENSE.txt
|
178
164
|
- README.md
|
@@ -180,41 +166,65 @@ files:
|
|
180
166
|
- bin/rubotium
|
181
167
|
- lib/rubotium.rb
|
182
168
|
- lib/rubotium/adb.rb
|
183
|
-
- lib/rubotium/adb/
|
169
|
+
- lib/rubotium/adb/commands.rb
|
170
|
+
- lib/rubotium/adb/commands/command.rb
|
171
|
+
- lib/rubotium/adb/commands/install_command.rb
|
172
|
+
- lib/rubotium/adb/commands/instrument_command.rb
|
173
|
+
- lib/rubotium/adb/commands/memory_command.rb
|
174
|
+
- lib/rubotium/adb/commands/pull_command.rb
|
175
|
+
- lib/rubotium/adb/commands/shell_command.rb
|
176
|
+
- lib/rubotium/adb/commands/uninstall_command.rb
|
184
177
|
- lib/rubotium/adb/devices.rb
|
185
|
-
- lib/rubotium/adb/
|
186
|
-
- lib/rubotium/adb/
|
178
|
+
- lib/rubotium/adb/parsers.rb
|
179
|
+
- lib/rubotium/adb/parsers/procrank.rb
|
180
|
+
- lib/rubotium/adb/parsers/single_test_result_parser.rb
|
181
|
+
- lib/rubotium/adb/parsers/test_results_parser.rb
|
187
182
|
- lib/rubotium/adb/shell.rb
|
188
183
|
- lib/rubotium/adb/test_result_parser.rb
|
189
|
-
- lib/rubotium/adb/uninstall_command.rb
|
190
184
|
- lib/rubotium/apk.rb
|
191
|
-
- lib/rubotium/apk/
|
185
|
+
- lib/rubotium/apk/android_apk.rb
|
192
186
|
- lib/rubotium/cmd.rb
|
193
187
|
- lib/rubotium/device.rb
|
194
188
|
- lib/rubotium/devices.rb
|
195
189
|
- lib/rubotium/formatters/junit_formatter.rb
|
196
|
-
- lib/rubotium/
|
197
|
-
- lib/rubotium/
|
190
|
+
- lib/rubotium/memory.rb
|
191
|
+
- lib/rubotium/memory/data_point.rb
|
192
|
+
- lib/rubotium/memory/monitor.rb
|
198
193
|
- lib/rubotium/package.rb
|
199
|
-
- lib/rubotium/
|
200
|
-
- lib/rubotium/
|
201
|
-
- lib/rubotium/
|
194
|
+
- lib/rubotium/runnable_test.rb
|
195
|
+
- lib/rubotium/test_cases_reader.rb
|
196
|
+
- lib/rubotium/test_result.rb
|
197
|
+
- lib/rubotium/test_results.rb
|
198
|
+
- lib/rubotium/test_runners/instrumentation_test_runner.rb
|
199
|
+
- lib/rubotium/tests_runner.rb
|
202
200
|
- lib/rubotium/version.rb
|
203
201
|
- rubotium.gemspec
|
204
202
|
- spec/fixtures/adb_devices_results.rb
|
203
|
+
- spec/fixtures/adb_raw_result.rb
|
204
|
+
- spec/fixtures/adb_raw_results.rb
|
205
205
|
- spec/fixtures/adb_results.rb
|
206
206
|
- spec/fixtures/jar_contents.rb
|
207
207
|
- spec/fixtures/javap_classes.rb
|
208
208
|
- spec/lib/rubotium/adb/adb_devices_spec.rb
|
209
|
-
- spec/lib/rubotium/adb/adb_instrumentation_spec.rb
|
210
209
|
- spec/lib/rubotium/adb/adb_result_parser_spec.rb
|
211
210
|
- spec/lib/rubotium/adb/adb_shell_spec.rb
|
211
|
+
- spec/lib/rubotium/adb/parsers/procrank_spec.rb
|
212
|
+
- spec/lib/rubotium/adb/parsers/single_test_result_parser_spec.rb
|
213
|
+
- spec/lib/rubotium/adb/parsers/test_results_parser_spec.rb
|
214
|
+
- spec/lib/rubotium/apk/android_apk_spec.rb
|
215
|
+
- spec/lib/rubotium/apk/mock/BarcodeScanner4.2.apk
|
216
|
+
- spec/lib/rubotium/apk/mock/UECExpress.apk
|
217
|
+
- spec/lib/rubotium/apk/mock/dummy.apk
|
218
|
+
- spec/lib/rubotium/apk/mock/sample.apk
|
219
|
+
- spec/lib/rubotium/device_spec.rb
|
212
220
|
- spec/lib/rubotium/devices_spec.rb
|
213
221
|
- spec/lib/rubotium/formatters/junit_formatter_spec.rb
|
214
|
-
- spec/lib/rubotium/
|
215
|
-
- spec/lib/rubotium/
|
222
|
+
- spec/lib/rubotium/memory/data_point_spec.rb
|
223
|
+
- spec/lib/rubotium/memory/monitor_spec.rb
|
224
|
+
- spec/lib/rubotium/tests_runner_spec.rb
|
216
225
|
- spec/lib/rubotium_spec.rb
|
217
226
|
- spec/spec_helper.rb
|
227
|
+
- test.rb
|
218
228
|
homepage: ''
|
219
229
|
licenses:
|
220
230
|
- MIT
|
@@ -225,12 +235,12 @@ require_paths:
|
|
225
235
|
- lib
|
226
236
|
required_ruby_version: !ruby/object:Gem::Requirement
|
227
237
|
requirements:
|
228
|
-
- -
|
238
|
+
- - '>='
|
229
239
|
- !ruby/object:Gem::Version
|
230
240
|
version: '0'
|
231
241
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
232
242
|
requirements:
|
233
|
-
- -
|
243
|
+
- - '>='
|
234
244
|
- !ruby/object:Gem::Version
|
235
245
|
version: '0'
|
236
246
|
requirements: []
|
@@ -241,16 +251,27 @@ specification_version: 4
|
|
241
251
|
summary: Run your Robotium tests with ease
|
242
252
|
test_files:
|
243
253
|
- spec/fixtures/adb_devices_results.rb
|
254
|
+
- spec/fixtures/adb_raw_result.rb
|
255
|
+
- spec/fixtures/adb_raw_results.rb
|
244
256
|
- spec/fixtures/adb_results.rb
|
245
257
|
- spec/fixtures/jar_contents.rb
|
246
258
|
- spec/fixtures/javap_classes.rb
|
247
259
|
- spec/lib/rubotium/adb/adb_devices_spec.rb
|
248
|
-
- spec/lib/rubotium/adb/adb_instrumentation_spec.rb
|
249
260
|
- spec/lib/rubotium/adb/adb_result_parser_spec.rb
|
250
261
|
- spec/lib/rubotium/adb/adb_shell_spec.rb
|
262
|
+
- spec/lib/rubotium/adb/parsers/procrank_spec.rb
|
263
|
+
- spec/lib/rubotium/adb/parsers/single_test_result_parser_spec.rb
|
264
|
+
- spec/lib/rubotium/adb/parsers/test_results_parser_spec.rb
|
265
|
+
- spec/lib/rubotium/apk/android_apk_spec.rb
|
266
|
+
- spec/lib/rubotium/apk/mock/BarcodeScanner4.2.apk
|
267
|
+
- spec/lib/rubotium/apk/mock/UECExpress.apk
|
268
|
+
- spec/lib/rubotium/apk/mock/dummy.apk
|
269
|
+
- spec/lib/rubotium/apk/mock/sample.apk
|
270
|
+
- spec/lib/rubotium/device_spec.rb
|
251
271
|
- spec/lib/rubotium/devices_spec.rb
|
252
272
|
- spec/lib/rubotium/formatters/junit_formatter_spec.rb
|
253
|
-
- spec/lib/rubotium/
|
254
|
-
- spec/lib/rubotium/
|
273
|
+
- spec/lib/rubotium/memory/data_point_spec.rb
|
274
|
+
- spec/lib/rubotium/memory/monitor_spec.rb
|
275
|
+
- spec/lib/rubotium/tests_runner_spec.rb
|
255
276
|
- spec/lib/rubotium_spec.rb
|
256
277
|
- spec/spec_helper.rb
|
data/lib/rubotium/adb/command.rb
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
module Rubotium
|
2
|
-
module Adb
|
3
|
-
class Command
|
4
|
-
def initialize(device_serial)
|
5
|
-
@device_serial = device_serial
|
6
|
-
end
|
7
|
-
|
8
|
-
def execute(command_to_run)
|
9
|
-
puts "EXECUTING_COMMAND: #{adb_command} #{command_to_run.executable_command}"
|
10
|
-
CMD.run_command(adb_command + " " + command_to_run.executable_command)
|
11
|
-
end
|
12
|
-
|
13
|
-
private
|
14
|
-
attr_reader :device_serial
|
15
|
-
|
16
|
-
def adb_command
|
17
|
-
"adb -s #{device_serial} "
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
module Rubotium
|
2
|
-
module Adb
|
3
|
-
class InstallCommand
|
4
|
-
COMMAND = 'install'
|
5
|
-
def initialize(apk_path)
|
6
|
-
@apk_path = apk_path
|
7
|
-
end
|
8
|
-
|
9
|
-
def executable_command
|
10
|
-
"#{COMMAND} #{apk_path}"
|
11
|
-
end
|
12
|
-
|
13
|
-
private
|
14
|
-
attr_reader :apk_path
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
@@ -1,36 +0,0 @@
|
|
1
|
-
module Rubotium
|
2
|
-
module Adb
|
3
|
-
class NoTestRunnerError < StandardError; end
|
4
|
-
class NoTestPackageError < StandardError; end
|
5
|
-
|
6
|
-
class Instrumentation
|
7
|
-
attr_accessor :test_package_name, :test_runner
|
8
|
-
attr_reader :adb_shell
|
9
|
-
|
10
|
-
def initialize(device)
|
11
|
-
@adb_shell = Rubotium::Adb::Shell.new(device)
|
12
|
-
end
|
13
|
-
|
14
|
-
def run_test(runable_test)
|
15
|
-
check_packages
|
16
|
-
result = adb_shell.run_command(instrument_command(runable_test.package_name, runable_test.test_name))
|
17
|
-
TestResultParser.new(result, runable_test.package_name, runable_test.test_name)
|
18
|
-
end
|
19
|
-
|
20
|
-
private
|
21
|
-
def instrument_command package_name, test_name
|
22
|
-
"am instrument -w -e class #{class_test(package_name, test_name)} #{test_package_name}/#{test_runner}"
|
23
|
-
end
|
24
|
-
|
25
|
-
def class_test package_name, test_name
|
26
|
-
"#{package_name}##{test_name}"
|
27
|
-
end
|
28
|
-
|
29
|
-
def check_packages
|
30
|
-
raise NoTestRunnerError if !test_runner
|
31
|
-
raise NoTestPackageError if !test_package_name
|
32
|
-
end
|
33
|
-
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
module Rubotium
|
2
|
-
module Adb
|
3
|
-
class UninstallCommand
|
4
|
-
COMMAND = 'uninstall'
|
5
|
-
def initialize(package_name)
|
6
|
-
@package_name = package_name
|
7
|
-
end
|
8
|
-
|
9
|
-
def executable_command
|
10
|
-
"#{COMMAND} #{package_name}"
|
11
|
-
end
|
12
|
-
|
13
|
-
private
|
14
|
-
attr_reader :package_name
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
require 'dex2jar'
|
2
|
-
module Rubotium
|
3
|
-
module Apk
|
4
|
-
class Converter
|
5
|
-
def initialize(apk_path, output_path)
|
6
|
-
@apk_path = apk_path
|
7
|
-
@output_path = output_path
|
8
|
-
end
|
9
|
-
|
10
|
-
def convert_to_jar
|
11
|
-
Dex2jar.execute("-f -o #{output_path}", [apk_path])
|
12
|
-
end
|
13
|
-
|
14
|
-
private
|
15
|
-
attr_reader :apk_path, :output_path
|
16
|
-
|
17
|
-
def file_exists?
|
18
|
-
File.exist? apk_path
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
data/lib/rubotium/grouper.rb
DELETED
@@ -1,40 +0,0 @@
|
|
1
|
-
module Rubotium
|
2
|
-
class Grouper
|
3
|
-
def initialize(test_suites, num_of_groups)
|
4
|
-
@test_suites = test_suites
|
5
|
-
@num_of_groups = num_of_groups
|
6
|
-
end
|
7
|
-
|
8
|
-
def create_groups
|
9
|
-
runnable_tests.each{|runnable|
|
10
|
-
next_bucket.push(runnable)
|
11
|
-
}
|
12
|
-
buckets
|
13
|
-
end
|
14
|
-
|
15
|
-
def runnable_tests
|
16
|
-
test_suites.map {|test_suite|
|
17
|
-
test_suite.test_cases.map{|test|
|
18
|
-
RunableTest.new(test_suite.name, test.name)
|
19
|
-
}
|
20
|
-
}.flatten
|
21
|
-
end
|
22
|
-
|
23
|
-
def next_bucket
|
24
|
-
buckets_enum.next
|
25
|
-
end
|
26
|
-
|
27
|
-
def buckets_enum
|
28
|
-
@buckets_enum ||= buckets.cycle
|
29
|
-
end
|
30
|
-
|
31
|
-
|
32
|
-
def buckets
|
33
|
-
@buckets ||= Array.new(num_of_groups) { [] }
|
34
|
-
end
|
35
|
-
|
36
|
-
private
|
37
|
-
attr_reader :test_suites, :num_of_groups
|
38
|
-
|
39
|
-
end
|
40
|
-
end
|
data/lib/rubotium/jar_reader.rb
DELETED
@@ -1,70 +0,0 @@
|
|
1
|
-
require 'set'
|
2
|
-
module Rubotium
|
3
|
-
class JarReader
|
4
|
-
TEST_PATTERN = Regexp.new('public void (test.*)\(')
|
5
|
-
attr_reader :path_to_jar
|
6
|
-
|
7
|
-
def initialize(jar_path)
|
8
|
-
@path_to_jar = jar_path
|
9
|
-
end
|
10
|
-
|
11
|
-
def test_suites
|
12
|
-
Converter.new(classes_in_jar).convert
|
13
|
-
end
|
14
|
-
|
15
|
-
def get_tests
|
16
|
-
parse
|
17
|
-
end
|
18
|
-
|
19
|
-
private
|
20
|
-
def classes_in_jar
|
21
|
-
CMD.run_command("jar -tf #{path_to_jar} | grep '.class'")
|
22
|
-
end
|
23
|
-
|
24
|
-
def tests_in_class(suite_name)
|
25
|
-
CMD.run_command "javap -classpath #{path_to_jar} #{suite_name}"
|
26
|
-
end
|
27
|
-
|
28
|
-
def parse
|
29
|
-
test_suites.map{|test_suite|
|
30
|
-
tests_in_class(test_suite.name).scan(TEST_PATTERN).flatten.each{|test|
|
31
|
-
test_suite.add_test_case(TestCase.new(test))
|
32
|
-
}
|
33
|
-
test_suite
|
34
|
-
}.delete_if{|test_suite| test_suite.test_cases.empty?}
|
35
|
-
end
|
36
|
-
|
37
|
-
|
38
|
-
class Converter
|
39
|
-
attr_reader :list
|
40
|
-
def initialize(list_of_classes)
|
41
|
-
@list = list_of_classes.split
|
42
|
-
end
|
43
|
-
|
44
|
-
def convert
|
45
|
-
deduplicated_test_suites
|
46
|
-
end
|
47
|
-
|
48
|
-
private
|
49
|
-
def test_suites
|
50
|
-
converted_class_names.map{|class_name|
|
51
|
-
TestSuite.new(class_name)
|
52
|
-
}
|
53
|
-
end
|
54
|
-
|
55
|
-
def converted_class_names
|
56
|
-
list.map{|class_name|
|
57
|
-
class_name.gsub("/", ".")
|
58
|
-
.gsub(".class", "")
|
59
|
-
.gsub(/\$.*/, "")
|
60
|
-
}
|
61
|
-
end
|
62
|
-
|
63
|
-
def deduplicated_test_suites
|
64
|
-
test_suites.uniq{|test_suite|
|
65
|
-
test_suite.name
|
66
|
-
}
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
data/lib/rubotium/test_case.rb
DELETED
data/lib/rubotium/test_suite.rb
DELETED
@@ -1,32 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Rubotium::Adb::Instrumentation do
|
4
|
-
let (:instr) { described_class }
|
5
|
-
let(:runable_test) {double(RunableTest)}
|
6
|
-
|
7
|
-
context 'running tests' do
|
8
|
-
let (:inst) { instr.new(" ") }
|
9
|
-
it 'should raise error if test runner name is not set' do
|
10
|
-
inst.test_package_name = "test_package"
|
11
|
-
expect { inst.run_test(runable_test) }.to raise_error (Rubotium::Adb::NoTestRunnerError)
|
12
|
-
end
|
13
|
-
|
14
|
-
it 'should raise error if test package name is not set' do
|
15
|
-
inst.test_runner = "runner"
|
16
|
-
expect { inst.run_test(runable_test) }.to raise_error (Rubotium::Adb::NoTestPackageError)
|
17
|
-
end
|
18
|
-
|
19
|
-
it 'runs correct test' do
|
20
|
-
runable_test.stub(:package_name).and_return("package")
|
21
|
-
runable_test.stub(:test_name).and_return("test")
|
22
|
-
inst.test_package_name = "package_name"
|
23
|
-
inst.test_runner = "TestRunner"
|
24
|
-
|
25
|
-
command = "am instrument -w -e class package#test package_name/TestRunner"
|
26
|
-
Rubotium::Adb::Shell.any_instance.should_receive(:run_command).with(command)
|
27
|
-
Rubotium::Adb::Shell.any_instance.stub(:run_command).and_return(Fixtures::Adb.test_success)
|
28
|
-
inst.run_test(runable_test)
|
29
|
-
end
|
30
|
-
|
31
|
-
end
|
32
|
-
end
|
@@ -1,56 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Rubotium::Grouper do
|
4
|
-
let(:grouper) { described_class }
|
5
|
-
let(:testsuite1) {TestSuite.new('test_package1')}
|
6
|
-
let(:testsuite2) {TestSuite.new('test_package2')}
|
7
|
-
|
8
|
-
before do
|
9
|
-
RunableTest.should_receive(:new){|arg1, arg2|
|
10
|
-
"#{arg1}, #{arg2}"
|
11
|
-
}.at_least(:once)
|
12
|
-
end
|
13
|
-
|
14
|
-
def add_test_cases_to_testsuite(testsuite, test_case_names)
|
15
|
-
test_case_names.each{|name|
|
16
|
-
testsuite.add_test_case(TestCase.new(name))
|
17
|
-
}
|
18
|
-
end
|
19
|
-
|
20
|
-
it 'should create two equal groups' do
|
21
|
-
add_test_cases_to_testsuite(testsuite1, ['name1', 'name2', 'name3', 'name4'])
|
22
|
-
tests = [ testsuite1 ]
|
23
|
-
|
24
|
-
result = [
|
25
|
-
["test_package1, name1", "test_package1, name3"],
|
26
|
-
["test_package1, name2", "test_package1, name4"]
|
27
|
-
]
|
28
|
-
|
29
|
-
grouper.new(tests, 2).create_groups.should == result
|
30
|
-
end
|
31
|
-
|
32
|
-
it 'should create three equal groups' do
|
33
|
-
add_test_cases_to_testsuite(testsuite1, ['name1', 'name2', 'name4'])
|
34
|
-
add_test_cases_to_testsuite(testsuite2, ['name3'])
|
35
|
-
tests = [ testsuite1, testsuite2 ]
|
36
|
-
|
37
|
-
result = [
|
38
|
-
["test_package1, name1", "test_package2, name3"],
|
39
|
-
["test_package1, name2"],
|
40
|
-
["test_package1, name4"]
|
41
|
-
]
|
42
|
-
|
43
|
-
grouper.new(tests, 3).create_groups.should == result
|
44
|
-
end
|
45
|
-
|
46
|
-
it 'should create one group' do
|
47
|
-
add_test_cases_to_testsuite(testsuite1, ['name1', 'name2', 'name3', 'name4'])
|
48
|
-
tests = [ testsuite1 ]
|
49
|
-
|
50
|
-
grouper.new(tests, 1).create_groups.should have(1).items
|
51
|
-
grouper.new(tests, 1).create_groups.should == [
|
52
|
-
["test_package1, name1", "test_package1, name2", "test_package1, name3", "test_package1, name4"]
|
53
|
-
]
|
54
|
-
|
55
|
-
end
|
56
|
-
end
|
@@ -1,58 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
describe Rubotium::JarReader do
|
3
|
-
let(:jar_reader) {described_class.new("path")}
|
4
|
-
|
5
|
-
context "Given there are no classes in jar" do
|
6
|
-
before do
|
7
|
-
Rubotium::CMD.stub(:run_command).and_return("")
|
8
|
-
end
|
9
|
-
it 'should return empty array' do
|
10
|
-
jar_reader.test_suites.should be_kind_of Array
|
11
|
-
jar_reader.test_suites.should be_empty
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
context "Given there are classes in jar" do
|
16
|
-
before do
|
17
|
-
Rubotium::CMD.stub(:run_command).with("jar -tf path | grep '.class'").and_return(Fixtures::JarContents.multiple_classes)
|
18
|
-
Rubotium::CMD.stub(:run_command).with("javap -classpath path com.android.screens.HomeScreen").and_return(
|
19
|
-
Fixtures::JavaPClasses.class_with_no_tests
|
20
|
-
)
|
21
|
-
|
22
|
-
Rubotium::CMD.stub(:run_command).with("javap -classpath path com.android.auth.login.LoginFlowTest").and_return(
|
23
|
-
Fixtures::JavaPClasses.class_with_tests
|
24
|
-
)
|
25
|
-
end
|
26
|
-
|
27
|
-
it 'should return an array with classes' do
|
28
|
-
jar_reader.test_suites.should be_kind_of Array
|
29
|
-
jar_reader.test_suites.should_not be_empty
|
30
|
-
end
|
31
|
-
|
32
|
-
it 'should convert class names to valid format' do
|
33
|
-
jar_reader.test_suites.first.name.should eql "com.android.screens.HomeScreen"
|
34
|
-
end
|
35
|
-
|
36
|
-
it 'should get the pacakges with tests' do
|
37
|
-
tests = jar_reader.get_tests
|
38
|
-
tests.should have(1).item
|
39
|
-
end
|
40
|
-
|
41
|
-
it 'should know the tests per package' do
|
42
|
-
tests = jar_reader.get_tests
|
43
|
-
tests.first.test_cases.count.should == 8
|
44
|
-
end
|
45
|
-
|
46
|
-
end
|
47
|
-
|
48
|
-
|
49
|
-
context "Given there are duplicated classes in jar" do
|
50
|
-
before do
|
51
|
-
Rubotium::CMD.stub(:run_command).and_return(Fixtures::JarContents.duplicated_classes)
|
52
|
-
end
|
53
|
-
it 'deduplicates classess' do
|
54
|
-
jar_reader.test_suites.count.should == 1
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
end
|