Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(406)

Side by Side Diff: build/android/pylib/instrumentation/instrumentation_test_instance_test.py

Issue 2668203005: Reland allow JUnit3/4 tests within the same apk to be run by test_runner (Closed)
Patch Set: Change pickle version Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright 2014 The Chromium Authors. All rights reserved. 2 # Copyright 2014 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """Unit tests for instrumentation_test_instance.""" 6 """Unit tests for instrumentation_test_instance."""
7 7
8 # pylint: disable=protected-access 8 # pylint: disable=protected-access
9 9
10 import unittest 10 import unittest
(...skipping 26 matching lines...) Expand all
37 mock.patch('%s._initializeTestCoverageAttributes' % c)): 37 mock.patch('%s._initializeTestCoverageAttributes' % c)):
38 return instrumentation_test_instance.InstrumentationTestInstance( 38 return instrumentation_test_instance.InstrumentationTestInstance(
39 mock.MagicMock(), mock.MagicMock(), lambda s: None) 39 mock.MagicMock(), mock.MagicMock(), lambda s: None)
40 40
41 def testGetTests_noFilter(self): 41 def testGetTests_noFilter(self):
42 o = self.createTestInstance() 42 o = self.createTestInstance()
43 raw_tests = [ 43 raw_tests = [
44 { 44 {
45 'annotations': {'Feature': {'value': ['Foo']}}, 45 'annotations': {'Feature': {'value': ['Foo']}},
46 'class': 'org.chromium.test.SampleTest', 46 'class': 'org.chromium.test.SampleTest',
47 'superclass': 'java.lang.Object',
47 'methods': [ 48 'methods': [
48 { 49 {
49 'annotations': {'SmallTest': None}, 50 'annotations': {'SmallTest': None},
50 'method': 'testMethod1', 51 'method': 'testMethod1',
51 }, 52 },
52 { 53 {
53 'annotations': {'MediumTest': None}, 54 'annotations': {'MediumTest': None},
54 'method': 'testMethod2', 55 'method': 'testMethod2',
55 }, 56 },
56 ], 57 ],
57 }, 58 },
58 { 59 {
59 'annotations': {'Feature': {'value': ['Bar']}}, 60 'annotations': {'Feature': {'value': ['Bar']}},
60 'class': 'org.chromium.test.SampleTest2', 61 'class': 'org.chromium.test.SampleTest2',
62 'superclass': 'java.lang.Object',
61 'methods': [ 63 'methods': [
62 { 64 {
63 'annotations': {'SmallTest': None}, 65 'annotations': {'SmallTest': None},
64 'method': 'testMethod1', 66 'method': 'testMethod1',
65 }, 67 },
66 ], 68 ],
67 } 69 }
68 ] 70 ]
69 71
70 expected_tests = [ 72 expected_tests = [
71 { 73 {
72 'annotations': { 74 'annotations': {
73 'Feature': {'value': ['Foo']}, 75 'Feature': {'value': ['Foo']},
74 'SmallTest': None, 76 'SmallTest': None,
75 }, 77 },
76 'class': 'org.chromium.test.SampleTest', 78 'class': 'org.chromium.test.SampleTest',
77 'method': 'testMethod1', 79 'method': 'testMethod1',
80 'is_junit4': True,
78 }, 81 },
79 { 82 {
80 'annotations': { 83 'annotations': {
81 'Feature': {'value': ['Foo']}, 84 'Feature': {'value': ['Foo']},
82 'MediumTest': None, 85 'MediumTest': None,
83 }, 86 },
84 'class': 'org.chromium.test.SampleTest', 87 'class': 'org.chromium.test.SampleTest',
85 'method': 'testMethod2', 88 'method': 'testMethod2',
89 'is_junit4': True,
86 }, 90 },
87 { 91 {
88 'annotations': { 92 'annotations': {
89 'Feature': {'value': ['Bar']}, 93 'Feature': {'value': ['Bar']},
90 'SmallTest': None, 94 'SmallTest': None,
91 }, 95 },
92 'class': 'org.chromium.test.SampleTest2', 96 'class': 'org.chromium.test.SampleTest2',
93 'method': 'testMethod1', 97 'method': 'testMethod1',
98 'is_junit4': True,
94 }, 99 },
95 ] 100 ]
96 101
97 o._test_jar = 'path/to/test.jar' 102 o._test_jar = 'path/to/test.jar'
103 o._test_runner_junit4 = 'J4Runner'
98 with mock.patch(_INSTRUMENTATION_TEST_INSTANCE_PATH % '_GetTestsFromPickle', 104 with mock.patch(_INSTRUMENTATION_TEST_INSTANCE_PATH % '_GetTestsFromPickle',
99 return_value=raw_tests): 105 return_value=raw_tests):
100 actual_tests = o.GetTests() 106 actual_tests = o.GetTests()
101 107
102 self.assertEquals(actual_tests, expected_tests) 108 self.assertEquals(actual_tests, expected_tests)
103 109
104 def testGetTests_simpleGtestFilter(self): 110 def testGetTests_simpleGtestFilter(self):
105 o = self.createTestInstance() 111 o = self.createTestInstance()
106 raw_tests = [ 112 raw_tests = [
107 { 113 {
108 'annotations': {'Feature': {'value': ['Foo']}}, 114 'annotations': {'Feature': {'value': ['Foo']}},
109 'class': 'org.chromium.test.SampleTest', 115 'class': 'org.chromium.test.SampleTest',
116 'superclass': 'java.lang.Object',
110 'methods': [ 117 'methods': [
111 { 118 {
112 'annotations': {'SmallTest': None}, 119 'annotations': {'SmallTest': None},
113 'method': 'testMethod1', 120 'method': 'testMethod1',
114 }, 121 },
115 { 122 {
116 'annotations': {'MediumTest': None}, 123 'annotations': {'MediumTest': None},
117 'method': 'testMethod2', 124 'method': 'testMethod2',
118 }, 125 },
119 ], 126 ],
120 } 127 }
121 ] 128 ]
122 129
123 expected_tests = [ 130 expected_tests = [
124 { 131 {
125 'annotations': { 132 'annotations': {
126 'Feature': {'value': ['Foo']}, 133 'Feature': {'value': ['Foo']},
127 'SmallTest': None, 134 'SmallTest': None,
128 }, 135 },
129 'class': 'org.chromium.test.SampleTest', 136 'class': 'org.chromium.test.SampleTest',
137 'is_junit4': True,
130 'method': 'testMethod1', 138 'method': 'testMethod1',
131 }, 139 },
132 ] 140 ]
133 141
134 o._test_filter = 'org.chromium.test.SampleTest.testMethod1' 142 o._test_filter = 'org.chromium.test.SampleTest.testMethod1'
135 o._test_jar = 'path/to/test.jar' 143 o._test_jar = 'path/to/test.jar'
144 o._test_runner_junit4 = 'J4Runner'
136 with mock.patch(_INSTRUMENTATION_TEST_INSTANCE_PATH % '_GetTestsFromPickle', 145 with mock.patch(_INSTRUMENTATION_TEST_INSTANCE_PATH % '_GetTestsFromPickle',
137 return_value=raw_tests): 146 return_value=raw_tests):
138 actual_tests = o.GetTests() 147 actual_tests = o.GetTests()
139 148
140 self.assertEquals(actual_tests, expected_tests) 149 self.assertEquals(actual_tests, expected_tests)
141 150
142 def testGetTests_wildcardGtestFilter(self): 151 def testGetTests_wildcardGtestFilter(self):
143 o = self.createTestInstance() 152 o = self.createTestInstance()
144 raw_tests = [ 153 raw_tests = [
145 { 154 {
146 'annotations': {'Feature': {'value': ['Foo']}}, 155 'annotations': {'Feature': {'value': ['Foo']}},
147 'class': 'org.chromium.test.SampleTest', 156 'class': 'org.chromium.test.SampleTest',
157 'superclass': 'java.lang.Object',
148 'methods': [ 158 'methods': [
149 { 159 {
150 'annotations': {'SmallTest': None}, 160 'annotations': {'SmallTest': None},
151 'method': 'testMethod1', 161 'method': 'testMethod1',
152 }, 162 },
153 { 163 {
154 'annotations': {'MediumTest': None}, 164 'annotations': {'MediumTest': None},
155 'method': 'testMethod2', 165 'method': 'testMethod2',
156 }, 166 },
157 ], 167 ],
158 }, 168 },
159 { 169 {
160 'annotations': {'Feature': {'value': ['Bar']}}, 170 'annotations': {'Feature': {'value': ['Bar']}},
161 'class': 'org.chromium.test.SampleTest2', 171 'class': 'org.chromium.test.SampleTest2',
172 'superclass': 'java.lang.Object',
162 'methods': [ 173 'methods': [
163 { 174 {
164 'annotations': {'SmallTest': None}, 175 'annotations': {'SmallTest': None},
165 'method': 'testMethod1', 176 'method': 'testMethod1',
166 }, 177 },
167 ], 178 ],
168 } 179 }
169 ] 180 ]
170 181
171 expected_tests = [ 182 expected_tests = [
172 { 183 {
173 'annotations': { 184 'annotations': {
174 'Feature': {'value': ['Bar']}, 185 'Feature': {'value': ['Bar']},
175 'SmallTest': None, 186 'SmallTest': None,
176 }, 187 },
177 'class': 'org.chromium.test.SampleTest2', 188 'class': 'org.chromium.test.SampleTest2',
189 'is_junit4': True,
178 'method': 'testMethod1', 190 'method': 'testMethod1',
179 }, 191 },
180 ] 192 ]
181 193
182 o._test_filter = 'org.chromium.test.SampleTest2.*' 194 o._test_filter = 'org.chromium.test.SampleTest2.*'
183 o._test_jar = 'path/to/test.jar' 195 o._test_jar = 'path/to/test.jar'
196 o._test_runner_junit4 = 'J4Runner'
184 with mock.patch(_INSTRUMENTATION_TEST_INSTANCE_PATH % '_GetTestsFromPickle', 197 with mock.patch(_INSTRUMENTATION_TEST_INSTANCE_PATH % '_GetTestsFromPickle',
185 return_value=raw_tests): 198 return_value=raw_tests):
186 actual_tests = o.GetTests() 199 actual_tests = o.GetTests()
187 200
188 self.assertEquals(actual_tests, expected_tests) 201 self.assertEquals(actual_tests, expected_tests)
189 202
190 def testGetTests_negativeGtestFilter(self): 203 def testGetTests_negativeGtestFilter(self):
191 o = self.createTestInstance() 204 o = self.createTestInstance()
192 raw_tests = [ 205 raw_tests = [
193 { 206 {
194 'annotations': {'Feature': {'value': ['Foo']}}, 207 'annotations': {'Feature': {'value': ['Foo']}},
195 'class': 'org.chromium.test.SampleTest', 208 'class': 'org.chromium.test.SampleTest',
209 'superclass': 'java.lang.Object',
196 'methods': [ 210 'methods': [
197 { 211 {
198 'annotations': {'SmallTest': None}, 212 'annotations': {'SmallTest': None},
199 'method': 'testMethod1', 213 'method': 'testMethod1',
200 }, 214 },
201 { 215 {
202 'annotations': {'MediumTest': None}, 216 'annotations': {'MediumTest': None},
203 'method': 'testMethod2', 217 'method': 'testMethod2',
204 }, 218 },
205 ], 219 ],
206 }, 220 },
207 { 221 {
208 'annotations': {'Feature': {'value': ['Bar']}}, 222 'annotations': {'Feature': {'value': ['Bar']}},
209 'class': 'org.chromium.test.SampleTest2', 223 'class': 'org.chromium.test.SampleTest2',
224 'superclass': 'java.lang.Object',
210 'methods': [ 225 'methods': [
211 { 226 {
212 'annotations': {'SmallTest': None}, 227 'annotations': {'SmallTest': None},
213 'method': 'testMethod1', 228 'method': 'testMethod1',
214 }, 229 },
215 ], 230 ],
216 } 231 }
217 ] 232 ]
218 233
219 expected_tests = [ 234 expected_tests = [
220 { 235 {
221 'annotations': { 236 'annotations': {
222 'Feature': {'value': ['Foo']}, 237 'Feature': {'value': ['Foo']},
223 'MediumTest': None, 238 'MediumTest': None,
224 }, 239 },
225 'class': 'org.chromium.test.SampleTest', 240 'class': 'org.chromium.test.SampleTest',
241 'is_junit4': True,
226 'method': 'testMethod2', 242 'method': 'testMethod2',
227 }, 243 },
228 { 244 {
229 'annotations': { 245 'annotations': {
230 'Feature': {'value': ['Bar']}, 246 'Feature': {'value': ['Bar']},
231 'SmallTest': None, 247 'SmallTest': None,
232 }, 248 },
233 'class': 'org.chromium.test.SampleTest2', 249 'class': 'org.chromium.test.SampleTest2',
250 'is_junit4': True,
234 'method': 'testMethod1', 251 'method': 'testMethod1',
235 }, 252 },
236 ] 253 ]
237 254
238 o._test_filter = '*-org.chromium.test.SampleTest.testMethod1' 255 o._test_filter = '*-org.chromium.test.SampleTest.testMethod1'
239 o._test_jar = 'path/to/test.jar' 256 o._test_jar = 'path/to/test.jar'
257 o._test_runner_junit4 = 'J4Runner'
240 with mock.patch(_INSTRUMENTATION_TEST_INSTANCE_PATH % '_GetTestsFromPickle', 258 with mock.patch(_INSTRUMENTATION_TEST_INSTANCE_PATH % '_GetTestsFromPickle',
241 return_value=raw_tests): 259 return_value=raw_tests):
242 actual_tests = o.GetTests() 260 actual_tests = o.GetTests()
243 261
244 self.assertEquals(actual_tests, expected_tests) 262 self.assertEquals(actual_tests, expected_tests)
245 263
246 def testGetTests_annotationFilter(self): 264 def testGetTests_annotationFilter(self):
247 o = self.createTestInstance() 265 o = self.createTestInstance()
248 raw_tests = [ 266 raw_tests = [
249 { 267 {
250 'annotations': {'Feature': {'value': ['Foo']}}, 268 'annotations': {'Feature': {'value': ['Foo']}},
251 'class': 'org.chromium.test.SampleTest', 269 'class': 'org.chromium.test.SampleTest',
270 'superclass': 'java.lang.Object',
252 'methods': [ 271 'methods': [
253 { 272 {
254 'annotations': {'SmallTest': None}, 273 'annotations': {'SmallTest': None},
255 'method': 'testMethod1', 274 'method': 'testMethod1',
256 }, 275 },
257 { 276 {
258 'annotations': {'MediumTest': None}, 277 'annotations': {'MediumTest': None},
259 'method': 'testMethod2', 278 'method': 'testMethod2',
260 }, 279 },
261 ], 280 ],
262 }, 281 },
263 { 282 {
264 'annotations': {'Feature': {'value': ['Bar']}}, 283 'annotations': {'Feature': {'value': ['Bar']}},
265 'class': 'org.chromium.test.SampleTest2', 284 'class': 'org.chromium.test.SampleTest2',
285 'superclass': 'java.lang.Object',
266 'methods': [ 286 'methods': [
267 { 287 {
268 'annotations': {'SmallTest': None}, 288 'annotations': {'SmallTest': None},
269 'method': 'testMethod1', 289 'method': 'testMethod1',
270 }, 290 },
271 ], 291 ],
272 } 292 }
273 ] 293 ]
274 294
275 expected_tests = [ 295 expected_tests = [
276 { 296 {
277 'annotations': { 297 'annotations': {
278 'Feature': {'value': ['Foo']}, 298 'Feature': {'value': ['Foo']},
279 'SmallTest': None, 299 'SmallTest': None,
280 }, 300 },
281 'class': 'org.chromium.test.SampleTest', 301 'class': 'org.chromium.test.SampleTest',
302 'is_junit4': True,
282 'method': 'testMethod1', 303 'method': 'testMethod1',
283 }, 304 },
284 { 305 {
285 'annotations': { 306 'annotations': {
286 'Feature': {'value': ['Bar']}, 307 'Feature': {'value': ['Bar']},
287 'SmallTest': None, 308 'SmallTest': None,
288 }, 309 },
289 'class': 'org.chromium.test.SampleTest2', 310 'class': 'org.chromium.test.SampleTest2',
311 'is_junit4': True,
290 'method': 'testMethod1', 312 'method': 'testMethod1',
291 }, 313 },
292 ] 314 ]
293 315
294 o._annotations = [('SmallTest', None)] 316 o._annotations = [('SmallTest', None)]
295 o._test_jar = 'path/to/test.jar' 317 o._test_jar = 'path/to/test.jar'
318 o._test_runner_junit4 = 'J4Runner'
296 with mock.patch(_INSTRUMENTATION_TEST_INSTANCE_PATH % '_GetTestsFromPickle', 319 with mock.patch(_INSTRUMENTATION_TEST_INSTANCE_PATH % '_GetTestsFromPickle',
297 return_value=raw_tests): 320 return_value=raw_tests):
298 actual_tests = o.GetTests() 321 actual_tests = o.GetTests()
299 322
300 self.assertEquals(actual_tests, expected_tests) 323 self.assertEquals(actual_tests, expected_tests)
301 324
302 def testGetTests_excludedAnnotationFilter(self): 325 def testGetTests_excludedAnnotationFilter(self):
303 o = self.createTestInstance() 326 o = self.createTestInstance()
304 raw_tests = [ 327 raw_tests = [
305 { 328 {
306 'annotations': {'Feature': {'value': ['Foo']}}, 329 'annotations': {'Feature': {'value': ['Foo']}},
307 'class': 'org.chromium.test.SampleTest', 330 'class': 'org.chromium.test.SampleTest',
331 'superclass': 'junit.framework.TestCase',
308 'methods': [ 332 'methods': [
309 { 333 {
310 'annotations': {'SmallTest': None}, 334 'annotations': {'SmallTest': None},
311 'method': 'testMethod1', 335 'method': 'testMethod1',
312 }, 336 },
313 { 337 {
314 'annotations': {'MediumTest': None}, 338 'annotations': {'MediumTest': None},
315 'method': 'testMethod2', 339 'method': 'testMethod2',
316 }, 340 },
317 ], 341 ],
318 }, 342 },
319 { 343 {
320 'annotations': {'Feature': {'value': ['Bar']}}, 344 'annotations': {'Feature': {'value': ['Bar']}},
321 'class': 'org.chromium.test.SampleTest2', 345 'class': 'org.chromium.test.SampleTest2',
346 'superclass': 'junit.framework.TestCase',
322 'methods': [ 347 'methods': [
323 { 348 {
324 'annotations': {'SmallTest': None}, 349 'annotations': {'SmallTest': None},
325 'method': 'testMethod1', 350 'method': 'testMethod1',
326 }, 351 },
327 ], 352 ],
328 } 353 }
329 ] 354 ]
330 355
331 expected_tests = [ 356 expected_tests = [
332 { 357 {
333 'annotations': { 358 'annotations': {
334 'Feature': {'value': ['Foo']}, 359 'Feature': {'value': ['Foo']},
335 'MediumTest': None, 360 'MediumTest': None,
336 }, 361 },
337 'class': 'org.chromium.test.SampleTest', 362 'class': 'org.chromium.test.SampleTest',
363 'is_junit4': False,
338 'method': 'testMethod2', 364 'method': 'testMethod2',
339 }, 365 },
340 ] 366 ]
341 367
342 o._excluded_annotations = [('SmallTest', None)] 368 o._excluded_annotations = [('SmallTest', None)]
343 o._test_jar = 'path/to/test.jar' 369 o._test_jar = 'path/to/test.jar'
370 o._test_runner_junit4 = 'J4Runner'
344 with mock.patch(_INSTRUMENTATION_TEST_INSTANCE_PATH % '_GetTestsFromPickle', 371 with mock.patch(_INSTRUMENTATION_TEST_INSTANCE_PATH % '_GetTestsFromPickle',
345 return_value=raw_tests): 372 return_value=raw_tests):
346 actual_tests = o.GetTests() 373 actual_tests = o.GetTests()
347 374
348 self.assertEquals(actual_tests, expected_tests) 375 self.assertEquals(actual_tests, expected_tests)
349 376
350 def testGetTests_annotationSimpleValueFilter(self): 377 def testGetTests_annotationSimpleValueFilter(self):
351 o = self.createTestInstance() 378 o = self.createTestInstance()
352 raw_tests = [ 379 raw_tests = [
353 { 380 {
354 'annotations': {'Feature': {'value': ['Foo']}}, 381 'annotations': {'Feature': {'value': ['Foo']}},
355 'class': 'org.chromium.test.SampleTest', 382 'class': 'org.chromium.test.SampleTest',
383 'superclass': 'junit.framework.TestCase',
356 'methods': [ 384 'methods': [
357 { 385 {
358 'annotations': { 386 'annotations': {
359 'SmallTest': None, 387 'SmallTest': None,
360 'TestValue': '1', 388 'TestValue': '1',
361 }, 389 },
362 'method': 'testMethod1', 390 'method': 'testMethod1',
363 }, 391 },
364 { 392 {
365 'annotations': { 393 'annotations': {
366 'MediumTest': None, 394 'MediumTest': None,
367 'TestValue': '2', 395 'TestValue': '2',
368 }, 396 },
369 'method': 'testMethod2', 397 'method': 'testMethod2',
370 }, 398 },
371 ], 399 ],
372 }, 400 },
373 { 401 {
374 'annotations': {'Feature': {'value': ['Bar']}}, 402 'annotations': {'Feature': {'value': ['Bar']}},
375 'class': 'org.chromium.test.SampleTest2', 403 'class': 'org.chromium.test.SampleTest2',
404 'superclass': 'junit.framework.TestCase',
376 'methods': [ 405 'methods': [
377 { 406 {
378 'annotations': { 407 'annotations': {
379 'SmallTest': None, 408 'SmallTest': None,
380 'TestValue': '3', 409 'TestValue': '3',
381 }, 410 },
382 'method': 'testMethod1', 411 'method': 'testMethod1',
383 }, 412 },
384 ], 413 ],
385 } 414 }
386 ] 415 ]
387 416
388 expected_tests = [ 417 expected_tests = [
389 { 418 {
390 'annotations': { 419 'annotations': {
391 'Feature': {'value': ['Foo']}, 420 'Feature': {'value': ['Foo']},
392 'SmallTest': None, 421 'SmallTest': None,
393 'TestValue': '1', 422 'TestValue': '1',
394 }, 423 },
395 'class': 'org.chromium.test.SampleTest', 424 'class': 'org.chromium.test.SampleTest',
425 'is_junit4': False,
396 'method': 'testMethod1', 426 'method': 'testMethod1',
397 }, 427 },
398 ] 428 ]
399 429
400 o._annotations = [('TestValue', '1')] 430 o._annotations = [('TestValue', '1')]
401 o._test_jar = 'path/to/test.jar' 431 o._test_jar = 'path/to/test.jar'
432 o._test_runner_junit4 = 'J4Runner'
402 with mock.patch(_INSTRUMENTATION_TEST_INSTANCE_PATH % '_GetTestsFromPickle', 433 with mock.patch(_INSTRUMENTATION_TEST_INSTANCE_PATH % '_GetTestsFromPickle',
403 return_value=raw_tests): 434 return_value=raw_tests):
404 actual_tests = o.GetTests() 435 actual_tests = o.GetTests()
405 436
406 self.assertEquals(actual_tests, expected_tests) 437 self.assertEquals(actual_tests, expected_tests)
407 438
408 def testGetTests_annotationDictValueFilter(self): 439 def testGetTests_annotationDictValueFilter(self):
409 o = self.createTestInstance() 440 o = self.createTestInstance()
410 raw_tests = [ 441 raw_tests = [
411 { 442 {
412 'annotations': {'Feature': {'value': ['Foo']}}, 443 'annotations': {'Feature': {'value': ['Foo']}},
413 'class': 'org.chromium.test.SampleTest', 444 'class': 'org.chromium.test.SampleTest',
445 'superclass': 'java.lang.Object',
414 'methods': [ 446 'methods': [
415 { 447 {
416 'annotations': {'SmallTest': None}, 448 'annotations': {'SmallTest': None},
417 'method': 'testMethod1', 449 'method': 'testMethod1',
418 }, 450 },
419 { 451 {
420 'annotations': {'MediumTest': None}, 452 'annotations': {'MediumTest': None},
421 'method': 'testMethod2', 453 'method': 'testMethod2',
422 }, 454 },
423 ], 455 ],
424 }, 456 },
425 { 457 {
426 'annotations': {'Feature': {'value': ['Bar']}}, 458 'annotations': {'Feature': {'value': ['Bar']}},
427 'class': 'org.chromium.test.SampleTest2', 459 'class': 'org.chromium.test.SampleTest2',
460 'superclass': 'java.lang.Object',
428 'methods': [ 461 'methods': [
429 { 462 {
430 'annotations': {'SmallTest': None}, 463 'annotations': {'SmallTest': None},
431 'method': 'testMethod1', 464 'method': 'testMethod1',
432 }, 465 },
433 ], 466 ],
434 } 467 }
435 ] 468 ]
436 469
437 expected_tests = [ 470 expected_tests = [
438 { 471 {
439 'annotations': { 472 'annotations': {
440 'Feature': {'value': ['Bar']}, 473 'Feature': {'value': ['Bar']},
441 'SmallTest': None, 474 'SmallTest': None,
442 }, 475 },
443 'class': 'org.chromium.test.SampleTest2', 476 'class': 'org.chromium.test.SampleTest2',
477 'is_junit4': True,
444 'method': 'testMethod1', 478 'method': 'testMethod1',
445 }, 479 },
446 ] 480 ]
447 481
448 o._annotations = [('Feature', 'Bar')] 482 o._annotations = [('Feature', 'Bar')]
449 o._test_jar = 'path/to/test.jar' 483 o._test_jar = 'path/to/test.jar'
484 o._test_runner_junit4 = 'J4Runner'
450 with mock.patch(_INSTRUMENTATION_TEST_INSTANCE_PATH % '_GetTestsFromPickle', 485 with mock.patch(_INSTRUMENTATION_TEST_INSTANCE_PATH % '_GetTestsFromPickle',
451 return_value=raw_tests): 486 return_value=raw_tests):
452 actual_tests = o.GetTests() 487 actual_tests = o.GetTests()
453 488
454 self.assertEquals(actual_tests, expected_tests) 489 self.assertEquals(actual_tests, expected_tests)
455 490
456 def testGetTests_multipleAnnotationValuesRequested(self): 491 def testGetTests_multipleAnnotationValuesRequested(self):
457 o = self.createTestInstance() 492 o = self.createTestInstance()
458 raw_tests = [ 493 raw_tests = [
459 { 494 {
460 'annotations': {'Feature': {'value': ['Foo']}}, 495 'annotations': {'Feature': {'value': ['Foo']}},
461 'class': 'org.chromium.test.SampleTest', 496 'class': 'org.chromium.test.SampleTest',
497 'superclass': 'junit.framework.TestCase',
462 'methods': [ 498 'methods': [
463 { 499 {
464 'annotations': {'SmallTest': None}, 500 'annotations': {'SmallTest': None},
465 'method': 'testMethod1', 501 'method': 'testMethod1',
466 }, 502 },
467 { 503 {
468 'annotations': { 504 'annotations': {
469 'Feature': {'value': ['Baz']}, 505 'Feature': {'value': ['Baz']},
470 'MediumTest': None, 506 'MediumTest': None,
471 }, 507 },
472 'method': 'testMethod2', 508 'method': 'testMethod2',
473 }, 509 },
474 ], 510 ],
475 }, 511 },
476 { 512 {
477 'annotations': {'Feature': {'value': ['Bar']}}, 513 'annotations': {'Feature': {'value': ['Bar']}},
478 'class': 'org.chromium.test.SampleTest2', 514 'class': 'org.chromium.test.SampleTest2',
515 'superclass': 'junit.framework.TestCase',
479 'methods': [ 516 'methods': [
480 { 517 {
481 'annotations': {'SmallTest': None}, 518 'annotations': {'SmallTest': None},
482 'method': 'testMethod1', 519 'method': 'testMethod1',
483 }, 520 },
484 ], 521 ],
485 } 522 }
486 ] 523 ]
487 524
488 expected_tests = [ 525 expected_tests = [
489 { 526 {
490 'annotations': { 527 'annotations': {
491 'Feature': {'value': ['Baz']}, 528 'Feature': {'value': ['Baz']},
492 'MediumTest': None, 529 'MediumTest': None,
493 }, 530 },
494 'class': 'org.chromium.test.SampleTest', 531 'class': 'org.chromium.test.SampleTest',
532 'is_junit4': False,
495 'method': 'testMethod2', 533 'method': 'testMethod2',
496 }, 534 },
497 { 535 {
498 'annotations': { 536 'annotations': {
499 'Feature': {'value': ['Bar']}, 537 'Feature': {'value': ['Bar']},
500 'SmallTest': None, 538 'SmallTest': None,
501 }, 539 },
502 'class': 'org.chromium.test.SampleTest2', 540 'class': 'org.chromium.test.SampleTest2',
541 'is_junit4': False,
503 'method': 'testMethod1', 542 'method': 'testMethod1',
504 }, 543 },
505 ] 544 ]
506 545
507 o._annotations = [('Feature', 'Bar'), ('Feature', 'Baz')] 546 o._annotations = [('Feature', 'Bar'), ('Feature', 'Baz')]
508 o._test_jar = 'path/to/test.jar' 547 o._test_jar = 'path/to/test.jar'
548 o._test_runner_junit4 = 'J4Runner'
509 with mock.patch(_INSTRUMENTATION_TEST_INSTANCE_PATH % '_GetTestsFromPickle', 549 with mock.patch(_INSTRUMENTATION_TEST_INSTANCE_PATH % '_GetTestsFromPickle',
510 return_value=raw_tests): 550 return_value=raw_tests):
511 actual_tests = o.GetTests() 551 actual_tests = o.GetTests()
512 552
513 self.assertEquals(actual_tests, expected_tests) 553 self.assertEquals(actual_tests, expected_tests)
514 554
515 def testGenerateTestResults_noStatus(self): 555 def testGenerateTestResults_noStatus(self):
516 results = instrumentation_test_instance.GenerateTestResults( 556 results = instrumentation_test_instance.GenerateTestResults(
517 None, None, [], 0, 1000) 557 None, None, [], 0, 1000)
518 self.assertEqual([], results) 558 self.assertEqual([], results)
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
620 }), 660 }),
621 ] 661 ]
622 results = instrumentation_test_instance.GenerateTestResults( 662 results = instrumentation_test_instance.GenerateTestResults(
623 None, None, statuses, 0, 1000) 663 None, None, statuses, 0, 1000)
624 self.assertEqual(1, len(results)) 664 self.assertEqual(1, len(results))
625 self.assertEqual(base_test_result.ResultType.SKIP, results[0].GetType()) 665 self.assertEqual(base_test_result.ResultType.SKIP, results[0].GetType())
626 666
627 667
628 if __name__ == '__main__': 668 if __name__ == '__main__':
629 unittest.main(verbosity=2) 669 unittest.main(verbosity=2)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698