rubotium 0.0.4 → 0.0.7
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 +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
@@ -0,0 +1,61 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Rubotium::Adb::Parsers::Procrank do
|
4
|
+
context 'when process has not started' do
|
5
|
+
let(:parser) { described_class.new('')}
|
6
|
+
|
7
|
+
it 'returns zero value PID' do
|
8
|
+
parser.parse.pid.should eql(0)
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'returns zero value Vss' do
|
12
|
+
parser.parse.vss.should eql(0)
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'returns zero value Rss' do
|
16
|
+
parser.parse.rss.should eql(0)
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'returns zero value Pss' do
|
20
|
+
parser.parse.pss.should eql(0)
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'returns zero value Uss' do
|
24
|
+
parser.parse.uss.should eql(0)
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'returns empty cmdline' do
|
28
|
+
parser.parse.cmdline.should be_empty
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
context 'with process using memory' do
|
34
|
+
let(:parser) { described_class.new(' 814 20404K 20328K 3030K 2168K com.android.dialer')}
|
35
|
+
|
36
|
+
it 'returns PID' do
|
37
|
+
parser.parse.pid.should eql(814)
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'returns Vss' do
|
41
|
+
parser.parse.vss.should eql(20404)
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'returns Rss' do
|
45
|
+
parser.parse.rss.should eql(20328)
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'returns Pss' do
|
49
|
+
parser.parse.pss.should eql(3030)
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'returns Uss' do
|
53
|
+
parser.parse.uss.should eql(2168)
|
54
|
+
end
|
55
|
+
|
56
|
+
it 'returns cmdline' do
|
57
|
+
parser.parse.cmdline.should eql('com.android.dialer')
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,116 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Rubotium::Adb::Parsers::SingleTestResultParser do
|
4
|
+
context 'with successful test' do
|
5
|
+
let(:parser) { described_class.new(Fixtures::AdbRawResult.successful_test_result) }
|
6
|
+
|
7
|
+
it 'should return test name' do
|
8
|
+
expect(parser.test_name).to eql('testMenuCrash')
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'should return class name' do
|
12
|
+
expect(parser.class_name).to eql('com.soundcloud.android.MenuCrashTest')
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'should be passed' do
|
16
|
+
parser.should be_passed
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'should not be failed' do
|
20
|
+
parser.should_not be_failed
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'should not be errored' do
|
24
|
+
parser.should_not be_errored
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'should not have stack trace' do
|
28
|
+
parser.stack_trace.should be_empty
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
|
33
|
+
context 'with failed test' do
|
34
|
+
let(:parser) { described_class.new(Fixtures::AdbRawResult.single_failed_test_result) }
|
35
|
+
|
36
|
+
it 'should return test name' do
|
37
|
+
expect(parser.test_name).to eql('testMenuCrash')
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'should return class name' do
|
41
|
+
expect(parser.class_name).to eql('com.soundcloud.android.MenuCrashTest')
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'should not be passed' do
|
45
|
+
parser.should_not be_passed
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'should be failed' do
|
49
|
+
parser.should be_failed
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'should not be errored' do
|
53
|
+
parser.should_not be_errored
|
54
|
+
end
|
55
|
+
|
56
|
+
it 'should get the stack trace' do
|
57
|
+
parser.stack_trace.should == Fixtures::AdbRawResult.single_failed_test_stack_trace
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
context 'with errored test' do
|
62
|
+
let(:parser) { described_class.new(Fixtures::AdbRawResult.such_error_wow) }
|
63
|
+
|
64
|
+
it 'should return test name' do
|
65
|
+
expect(parser.test_name).to eql('testMenuCrash')
|
66
|
+
end
|
67
|
+
|
68
|
+
it 'should return class name' do
|
69
|
+
expect(parser.class_name).to eql('com.soundcloud.android.MenuCrashTest')
|
70
|
+
end
|
71
|
+
|
72
|
+
it 'should not be passed' do
|
73
|
+
parser.should_not be_passed
|
74
|
+
end
|
75
|
+
|
76
|
+
it 'should not be failed' do
|
77
|
+
parser.should_not be_failed
|
78
|
+
end
|
79
|
+
|
80
|
+
it 'should be errored' do
|
81
|
+
parser.should be_errored
|
82
|
+
end
|
83
|
+
|
84
|
+
it 'should get the stack trace' do
|
85
|
+
expect(parser.stack_trace).to eql(Fixtures::AdbRawResult.such_error_stack_trace)
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
context 'with errored test' do
|
90
|
+
let(:parser) { described_class.new(Fixtures::AdbRawResult.single_errored_test_result) }
|
91
|
+
|
92
|
+
it 'should return test name' do
|
93
|
+
expect(parser.test_name).to eql('testMenuCrash')
|
94
|
+
end
|
95
|
+
|
96
|
+
it 'should return class name' do
|
97
|
+
expect(parser.class_name).to eql('com.soundcloud.android.MenuCrashTest')
|
98
|
+
end
|
99
|
+
|
100
|
+
it 'should not be passed' do
|
101
|
+
parser.should_not be_passed
|
102
|
+
end
|
103
|
+
|
104
|
+
it 'should not be failed' do
|
105
|
+
parser.should_not be_failed
|
106
|
+
end
|
107
|
+
|
108
|
+
it 'should not be errored' do
|
109
|
+
parser.should be_errored
|
110
|
+
end
|
111
|
+
|
112
|
+
it 'should get the stack trace' do
|
113
|
+
parser.stack_trace.should == Fixtures::AdbRawResult.single_errored_test_result_stack_trace
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
@@ -0,0 +1,108 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Rubotium::Adb::Parsers::TestResultsParser do
|
4
|
+
context 'with multiple tests ' do
|
5
|
+
let(:parser) { described_class.new(Fixtures::AdbRawResults.multiple_test_results) }
|
6
|
+
|
7
|
+
it 'should return three test results' do
|
8
|
+
parser.count.should be 3
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'should be successful' do
|
12
|
+
expect(parser).to be_successful
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'should return time' do
|
16
|
+
expect(parser.time).to eql('0.142')
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'should not have error message' do
|
20
|
+
expect(parser.message).to be_empty
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
context 'with single test' do
|
25
|
+
let(:parser) { described_class.new(Fixtures::AdbRawResults.single_failed_test) }
|
26
|
+
|
27
|
+
it 'should return three test results' do
|
28
|
+
parser.count.should be 1
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'should be successful' do
|
32
|
+
expect(parser).to be_successful
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'should return time' do
|
36
|
+
expect(parser.time).to eql('16.79')
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'should not have error message' do
|
40
|
+
expect(parser.message).to be_empty
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
context 'when tests cannot start' do
|
45
|
+
let(:parser) { described_class.new(Fixtures::AdbRawResults.test_cannot_start_error) }
|
46
|
+
|
47
|
+
it 'should return 0 test results' do
|
48
|
+
parser.count.should be 0
|
49
|
+
end
|
50
|
+
|
51
|
+
it 'should be failed' do
|
52
|
+
expect(parser).to be_failed
|
53
|
+
end
|
54
|
+
|
55
|
+
it 'should return time = 0' do
|
56
|
+
expect(parser.time).to eql('0')
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'should return error message' do
|
60
|
+
error_message = "Unable to find instrumentation info for: " +
|
61
|
+
"ComponentInfo{com.soundcloud.android.tests/com.soundcloud.android.tests.RandomizingRunnr}"
|
62
|
+
expect(parser.message).to eql(error_message)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
context 'when tests throw error' do
|
67
|
+
let(:parser) { described_class.new(Fixtures::AdbRawResults.test_run_error) }
|
68
|
+
|
69
|
+
it 'should return 0 test results' do
|
70
|
+
parser.count.should be 0
|
71
|
+
end
|
72
|
+
|
73
|
+
it 'should be failed' do
|
74
|
+
expect(parser).to be_failed
|
75
|
+
end
|
76
|
+
|
77
|
+
it 'should return time = 0' do
|
78
|
+
expect(parser.time).to eql('0')
|
79
|
+
end
|
80
|
+
|
81
|
+
it 'should return error message' do
|
82
|
+
error_message = "java.lang.RuntimeException\njava.lang.RuntimeException: " +
|
83
|
+
"Could not find test class. Class: com.soundcloud.android.MenuCrashTests"
|
84
|
+
expect(parser.message).to eql(error_message)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
context 'when application crashes during test execution' do
|
89
|
+
let(:parser) { described_class.new(Fixtures::AdbRawResults.app_crashed_during_tests) }
|
90
|
+
|
91
|
+
it 'should return 0 test results' do
|
92
|
+
parser.count.should be 0
|
93
|
+
end
|
94
|
+
|
95
|
+
it 'should be failed' do
|
96
|
+
expect(parser).to be_failed
|
97
|
+
end
|
98
|
+
|
99
|
+
it 'should return time = 0' do
|
100
|
+
expect(parser.time).to eql('0')
|
101
|
+
end
|
102
|
+
|
103
|
+
it 'should return error message' do
|
104
|
+
error_message = "java.lang.RuntimeException\njava.lang.RuntimeException: developer requested crash"
|
105
|
+
expect(parser.message).to eql(error_message)
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
# encoding: utf-8
|
4
|
+
require "pp"
|
5
|
+
|
6
|
+
describe Rubotium::Apk::AndroidApk do
|
7
|
+
|
8
|
+
sample_file_path = File.dirname(__FILE__) + "/mock/sample.apk"
|
9
|
+
sample2_file_path = File.dirname(__FILE__) + "/mock/BarcodeScanner4.2.apk"
|
10
|
+
icon_not_set_file_path = File.dirname(__FILE__) + "/mock/UECExpress.apk"
|
11
|
+
dummy_file_path = File.dirname(__FILE__) + "/mock/dummy.apk"
|
12
|
+
|
13
|
+
context 'with non existing apk' do
|
14
|
+
let(:apk) { described_class.new('dummy.apk') }
|
15
|
+
|
16
|
+
it "should raise exception" do
|
17
|
+
expect{apk}.to raise_exception(Errno::ENOENT)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
context 'with not readable apk' do
|
22
|
+
let(:apk) { described_class.new(dummy_file_path) }
|
23
|
+
|
24
|
+
it 'should raise exception' do
|
25
|
+
expect{apk.package_name}.to raise_error(RuntimeError, /ERROR: dump failed because no AndroidManifest.xml found/)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
context 'with valid apk file' do
|
30
|
+
let(:apk) { described_class.new(sample_file_path) }
|
31
|
+
|
32
|
+
it 'should read package_name' do
|
33
|
+
expect(apk.package_name).to eql 'com.example.sample'
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
end
|
Binary file
|
Binary file
|
@@ -0,0 +1 @@
|
|
1
|
+
dummy
|
Binary file
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Rubotium::Device do
|
4
|
+
let(:device) { described_class.new('12345') }
|
5
|
+
let(:command) { double(Rubotium::Adb::Commands::Command)}
|
6
|
+
before do
|
7
|
+
device.stub(:adb_command).and_return(command)
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'installs package on device' do
|
11
|
+
path_to_apk = 'path/to/apk'
|
12
|
+
expect(command).to receive(:install).with(path_to_apk)
|
13
|
+
device.install(path_to_apk)
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'uninstalls package from device' do
|
17
|
+
package_name = 'com.package.name'
|
18
|
+
expect(command).to receive(:uninstall).with(package_name)
|
19
|
+
device.uninstall(package_name)
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'pulls files from device' do
|
23
|
+
files_to_pull = '/sdcard/files/'
|
24
|
+
expect(command).to receive(:pull).with(files_to_pull)
|
25
|
+
device.pull(files_to_pull)
|
26
|
+
end
|
27
|
+
|
28
|
+
it "knows it's name" do
|
29
|
+
expect(command).to receive(:shell).with("getprop ro.product.model").and_return('MyNameIs')
|
30
|
+
expect(device.name).to eql('MyNameIs')
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'executes shell commands' do
|
34
|
+
getprop = 'getprop ro.product.model'
|
35
|
+
expect(command).to receive(:shell).with(getprop)
|
36
|
+
device.shell(getprop)
|
37
|
+
end
|
38
|
+
end
|
@@ -1,45 +1,62 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
+
require 'ostruct'
|
2
3
|
|
3
4
|
describe Rubotium::Devices do
|
4
|
-
let(:
|
5
|
+
let(:adb_devices) { double(Rubotium::Adb::Devices) }
|
6
|
+
let(:device) { OpenStruct.new(:name => "TestDevice", :serial => '1234') }
|
5
7
|
|
6
8
|
before do
|
7
|
-
Rubotium::Device.stub(:new).and_return(
|
9
|
+
Rubotium::Device.stub(:new).and_return(device)
|
8
10
|
end
|
9
11
|
|
10
|
-
context '
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
Rubotium::Adb::Devices.any_instance.stub(:list).and_return([])
|
15
|
-
expect { devices.all }.to raise_error(Rubotium::NoDevicesError)
|
12
|
+
context 'when attached device' do
|
13
|
+
before do
|
14
|
+
expect(adb_devices).to receive(:attached).and_return([device])
|
15
|
+
expect(devices).to receive(:adb_devices).and_return(adb_devices)
|
16
16
|
end
|
17
17
|
|
18
|
-
|
19
|
-
|
20
|
-
|
18
|
+
context 'is matched' do
|
19
|
+
let(:devices) { described_class.new(:name => 'TestDevice') }
|
20
|
+
|
21
|
+
it 'should return matched devices' do
|
22
|
+
devices.all.should == [device]
|
23
|
+
end
|
21
24
|
end
|
22
25
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
+
context 'is not matched' do
|
27
|
+
let(:devices) { described_class.new(:name => 'Nexus') }
|
28
|
+
|
29
|
+
it 'should raise exception about not matched devices' do
|
30
|
+
expect { devices.all }.to raise_error(Rubotium::NoMatchedDevicesError)
|
31
|
+
end
|
26
32
|
end
|
27
33
|
|
28
|
-
|
29
|
-
|
30
|
-
|
34
|
+
context 'without given matcher' do
|
35
|
+
let(:devices) { described_class.new }
|
36
|
+
|
37
|
+
it 'should return all available devices' do
|
38
|
+
devices.all.should == [device]
|
39
|
+
end
|
31
40
|
end
|
32
41
|
|
42
|
+
context 'with given serial' do
|
43
|
+
let(:devices) { described_class.new(:serial => '1234') }
|
44
|
+
|
45
|
+
it 'should return matched device' do
|
46
|
+
devices.all.should == [device]
|
47
|
+
end
|
48
|
+
end
|
33
49
|
end
|
34
50
|
|
35
|
-
context '
|
36
|
-
let(:devices) {
|
51
|
+
context 'with no devices attached' do
|
52
|
+
let(:devices) { described_class.new(:name => 'Nexus') }
|
37
53
|
|
38
|
-
|
39
|
-
Rubotium::Adb::Devices.any_instance.stub(:
|
40
|
-
devices.all.should == ["Device_Instance", "Device_Instance", "Device_Instance", "Device_Instance", "Device_Instance"]
|
54
|
+
before do
|
55
|
+
Rubotium::Adb::Devices.any_instance.stub(:attached).and_return([])
|
41
56
|
end
|
42
57
|
|
58
|
+
it 'should raise exception about device being not connected' do
|
59
|
+
expect { devices.all }.to raise_error(Rubotium::NoDevicesError)
|
60
|
+
end
|
43
61
|
end
|
44
|
-
|
45
|
-
end
|
62
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
describe Rubotium::Memory::DataPoint do
|
3
|
+
let(:time) { Time.parse("3:00:00") }
|
4
|
+
subject(:data_point) {described_class.new(time, "") }
|
5
|
+
|
6
|
+
context 'with procrank results' do
|
7
|
+
let(:procrank_results) { OpenStruct.new(
|
8
|
+
:pid => 0,
|
9
|
+
:vss => 1,
|
10
|
+
:rss => 2,
|
11
|
+
:pss => 3,
|
12
|
+
:uss => 4,
|
13
|
+
:cmdline => 'cmdline')
|
14
|
+
}
|
15
|
+
|
16
|
+
before do
|
17
|
+
parser = double(Rubotium::Adb::Parsers::Procrank)
|
18
|
+
expect(parser).to receive(:parse).and_return(procrank_results)
|
19
|
+
expect(data_point).to receive(:parser).and_return(parser)
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'returns pid' do
|
23
|
+
data_point.pid.should eql(0)
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'returns vss' do
|
27
|
+
data_point.vss.should eql(1)
|
28
|
+
end
|
29
|
+
it 'returns rss' do
|
30
|
+
data_point.rss.should eql(2)
|
31
|
+
end
|
32
|
+
it 'returns pss' do
|
33
|
+
data_point.pss.should eql(3)
|
34
|
+
end
|
35
|
+
it 'returns uss' do
|
36
|
+
data_point.uss.should eql(4)
|
37
|
+
end
|
38
|
+
it 'returns cmdline' do
|
39
|
+
data_point.cmdline.should eql('cmdline')
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'ostruct'
|
3
|
+
|
4
|
+
describe Rubotium::TestsRunner do
|
5
|
+
let(:device1) { double('Device1') }
|
6
|
+
let(:device2) { double('Device2') }
|
7
|
+
let(:devices) { [device1, device2] }
|
8
|
+
let(:tests) { (0..10).to_a.map{|elem| Rubotium::RunnableTest.new("package#{elem}", "name#{elem}")} }
|
9
|
+
let(:test_runner) { double(Rubotium::TestRunners::InstrumentationTestRunner) }
|
10
|
+
let(:test_package) { double(Rubotium::Package) }
|
11
|
+
let(:successful_test) {OpenStruct.new(:failed? => false )}
|
12
|
+
|
13
|
+
before do
|
14
|
+
device1.stub(:name).and_return('device1')
|
15
|
+
device2.stub(:name).and_return('device2')
|
16
|
+
test_package.stub(:test_runner).and_return('com.android.TestRunner')
|
17
|
+
test_package.stub(:name).and_return('com.android.test#testToRun')
|
18
|
+
end
|
19
|
+
context 'without extra options' do
|
20
|
+
let(:runner) { described_class.new(devices, tests, test_package) }
|
21
|
+
|
22
|
+
context 'when running tests' do
|
23
|
+
before do
|
24
|
+
device1.stub(:shell)
|
25
|
+
device2.stub(:shell)
|
26
|
+
runner.stub(:test_runner).and_return(test_runner)
|
27
|
+
test_runner.stub(:run_test).with(any_args).and_return(successful_test)
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'runs all the tests from the queue' do
|
31
|
+
runner.run_tests
|
32
|
+
expect(runner.send :tests_queue).to be_empty
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'executes tests on all devices' do
|
36
|
+
pending
|
37
|
+
expect(device1).to receive(:shell).exactly(1).times.and_return { sleep 1 }
|
38
|
+
expect(device2).to receive(:shell).exactly(10).times
|
39
|
+
runner.run_tests
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'knows how many tests it has' do
|
43
|
+
runner.tests_count.should eql(11)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -4,6 +4,8 @@ require 'fixtures/javap_classes'
|
|
4
4
|
require 'fixtures/jar_contents'
|
5
5
|
require 'fixtures/adb_results'
|
6
6
|
require 'fixtures/adb_devices_results'
|
7
|
+
require 'fixtures/adb_raw_results'
|
8
|
+
require 'fixtures/adb_raw_result'
|
7
9
|
require 'rspec/mocks'
|
8
10
|
|
9
11
|
SimpleCov.formatter = Coveralls::SimpleCov::Formatter
|