OLD | NEW |
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 import unittest | 6 import unittest |
7 | 7 |
8 from pylib.gtest import test_package | 8 from pylib.gtest import gtest_test_instance |
9 | |
10 # pylint: disable=W0212 | |
11 | 9 |
12 | 10 |
13 class TestPackageTest(unittest.TestCase): | 11 class GtestTestInstanceTests(unittest.TestCase): |
14 | 12 |
15 def testParseGTestListTests_simple(self): | 13 def testParseGTestListTests_simple(self): |
16 raw_output = [ | 14 raw_output = [ |
17 'TestCaseOne.', | 15 'TestCaseOne.', |
18 ' testOne', | 16 ' testOne', |
19 ' testTwo', | 17 ' testTwo', |
20 'TestCaseTwo.', | 18 'TestCaseTwo.', |
21 ' testThree', | 19 ' testThree', |
22 ' testFour', | 20 ' testFour', |
23 ] | 21 ] |
24 actual = test_package.TestPackage._ParseGTestListTests(raw_output) | 22 actual = gtest_test_instance.ParseGTestListTests(raw_output) |
25 expected = [ | 23 expected = [ |
26 'TestCaseOne.testOne', | 24 'TestCaseOne.testOne', |
27 'TestCaseOne.testTwo', | 25 'TestCaseOne.testTwo', |
28 'TestCaseTwo.testThree', | 26 'TestCaseTwo.testThree', |
29 'TestCaseTwo.testFour', | 27 'TestCaseTwo.testFour', |
30 ] | 28 ] |
31 self.assertEqual(expected, actual) | 29 self.assertEqual(expected, actual) |
32 | 30 |
33 def testParseGTestListTests_typeParameterized_old(self): | 31 def testParseGTestListTests_typeParameterized_old(self): |
34 raw_output = [ | 32 raw_output = [ |
35 'TPTestCase/WithTypeParam/0.', | 33 'TPTestCase/WithTypeParam/0.', |
36 ' testOne', | 34 ' testOne', |
37 ' testTwo', | 35 ' testTwo', |
38 ] | 36 ] |
39 actual = test_package.TestPackage._ParseGTestListTests(raw_output) | 37 actual = gtest_test_instance.ParseGTestListTests(raw_output) |
40 expected = [ | 38 expected = [ |
41 'TPTestCase/WithTypeParam/0.testOne', | 39 'TPTestCase/WithTypeParam/0.testOne', |
42 'TPTestCase/WithTypeParam/0.testTwo', | 40 'TPTestCase/WithTypeParam/0.testTwo', |
43 ] | 41 ] |
44 self.assertEqual(expected, actual) | 42 self.assertEqual(expected, actual) |
45 | 43 |
46 def testParseGTestListTests_typeParameterized_new(self): | 44 def testParseGTestListTests_typeParameterized_new(self): |
47 raw_output = [ | 45 raw_output = [ |
48 'TPTestCase/WithTypeParam/0. # TypeParam = TypeParam0', | 46 'TPTestCase/WithTypeParam/0. # TypeParam = TypeParam0', |
49 ' testOne', | 47 ' testOne', |
50 ' testTwo', | 48 ' testTwo', |
51 ] | 49 ] |
52 actual = test_package.TestPackage._ParseGTestListTests(raw_output) | 50 actual = gtest_test_instance.ParseGTestListTests(raw_output) |
53 expected = [ | 51 expected = [ |
54 'TPTestCase/WithTypeParam/0.testOne', | 52 'TPTestCase/WithTypeParam/0.testOne', |
55 'TPTestCase/WithTypeParam/0.testTwo', | 53 'TPTestCase/WithTypeParam/0.testTwo', |
56 ] | 54 ] |
57 self.assertEqual(expected, actual) | 55 self.assertEqual(expected, actual) |
58 | 56 |
59 def testParseGTestListTests_valueParameterized_old(self): | 57 def testParseGTestListTests_valueParameterized_old(self): |
60 raw_output = [ | 58 raw_output = [ |
61 'VPTestCase.', | 59 'VPTestCase.', |
62 ' testWithValueParam/0', | 60 ' testWithValueParam/0', |
63 ' testWithValueParam/1', | 61 ' testWithValueParam/1', |
64 ] | 62 ] |
65 actual = test_package.TestPackage._ParseGTestListTests(raw_output) | 63 actual = gtest_test_instance.ParseGTestListTests(raw_output) |
66 expected = [ | 64 expected = [ |
67 'VPTestCase.testWithValueParam/0', | 65 'VPTestCase.testWithValueParam/0', |
68 'VPTestCase.testWithValueParam/1', | 66 'VPTestCase.testWithValueParam/1', |
69 ] | 67 ] |
70 self.assertEqual(expected, actual) | 68 self.assertEqual(expected, actual) |
71 | 69 |
72 def testParseGTestListTests_valueParameterized_new(self): | 70 def testParseGTestListTests_valueParameterized_new(self): |
73 raw_output = [ | 71 raw_output = [ |
74 'VPTestCase.', | 72 'VPTestCase.', |
75 ' testWithValueParam/0 # GetParam() = 0', | 73 ' testWithValueParam/0 # GetParam() = 0', |
76 ' testWithValueParam/1 # GetParam() = 1', | 74 ' testWithValueParam/1 # GetParam() = 1', |
77 ] | 75 ] |
78 actual = test_package.TestPackage._ParseGTestListTests(raw_output) | 76 actual = gtest_test_instance.ParseGTestListTests(raw_output) |
79 expected = [ | 77 expected = [ |
80 'VPTestCase.testWithValueParam/0', | 78 'VPTestCase.testWithValueParam/0', |
81 'VPTestCase.testWithValueParam/1', | 79 'VPTestCase.testWithValueParam/1', |
82 ] | 80 ] |
83 self.assertEqual(expected, actual) | 81 self.assertEqual(expected, actual) |
84 | 82 |
85 | 83 |
86 if __name__ == '__main__': | 84 if __name__ == '__main__': |
87 unittest.main(verbosity=2) | 85 unittest.main(verbosity=2) |
88 | 86 |
OLD | NEW |