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
4 # found in the LICENSE file.
7 """Unit tests for instrumentation.TestRunner."""
9 # pylint: disable=W0212
15 from pylib
import constants
16 from pylib
.base
import base_test_result
17 from pylib
.instrumentation
import instrumentation_test_instance
19 sys
.path
.append(os
.path
.join(
20 constants
.DIR_SOURCE_ROOT
, 'third_party', 'pymock'))
21 import mock
# pylint: disable=F0401
24 class InstrumentationTestInstanceTest(unittest
.TestCase
):
30 def testGenerateTestResults_noStatus(self
):
31 results
= instrumentation_test_instance
.GenerateTestResults(
32 None, None, [], 0, 1000)
33 self
.assertEqual([], results
)
35 def testGenerateTestResults_testPassed(self
):
38 'class': 'test.package.TestClass',
42 'class': 'test.package.TestClass',
46 results
= instrumentation_test_instance
.GenerateTestResults(
47 None, None, statuses
, 0, 1000)
48 self
.assertEqual(1, len(results
))
49 self
.assertEqual(base_test_result
.ResultType
.PASS
, results
[0].GetType())
51 def testGenerateTestResults_testSkipped_true(self
):
54 'class': 'test.package.TestClass',
58 'test_skipped': 'true',
59 'class': 'test.package.TestClass',
63 'class': 'test.package.TestClass',
67 results
= instrumentation_test_instance
.GenerateTestResults(
68 None, None, statuses
, 0, 1000)
69 self
.assertEqual(1, len(results
))
70 self
.assertEqual(base_test_result
.ResultType
.SKIP
, results
[0].GetType())
72 def testGenerateTestResults_testSkipped_false(self
):
75 'class': 'test.package.TestClass',
79 'test_skipped': 'false',
82 'class': 'test.package.TestClass',
86 results
= instrumentation_test_instance
.GenerateTestResults(
87 None, None, statuses
, 0, 1000)
88 self
.assertEqual(1, len(results
))
89 self
.assertEqual(base_test_result
.ResultType
.PASS
, results
[0].GetType())
91 def testGenerateTestResults_testFailed(self
):
94 'class': 'test.package.TestClass',
98 'class': 'test.package.TestClass',
102 results
= instrumentation_test_instance
.GenerateTestResults(
103 None, None, statuses
, 0, 1000)
104 self
.assertEqual(1, len(results
))
105 self
.assertEqual(base_test_result
.ResultType
.FAIL
, results
[0].GetType())
108 if __name__
== '__main__':
109 unittest
.main(verbosity
=2)