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.base import base_test_result | 8 from pylib.base import base_test_result |
9 from pylib.results import json_results | 9 from pylib.results import json_results |
10 | 10 |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 | 121 |
122 for test_name, iteration_result in iterations[0].iteritems(): | 122 for test_name, iteration_result in iterations[0].iteritems(): |
123 self.assertTrue(test_name in expected_tests) | 123 self.assertTrue(test_name in expected_tests) |
124 expected_tests.remove(test_name) | 124 expected_tests.remove(test_name) |
125 self.assertEquals(1, len(iteration_result)) | 125 self.assertEquals(1, len(iteration_result)) |
126 | 126 |
127 test_iteration_result = iteration_result[0] | 127 test_iteration_result = iteration_result[0] |
128 self.assertTrue('status' in test_iteration_result) | 128 self.assertTrue('status' in test_iteration_result) |
129 self.assertEquals('SUCCESS', test_iteration_result['status']) | 129 self.assertEquals('SUCCESS', test_iteration_result['status']) |
130 | 130 |
| 131 def testGenerateResultsDict_passOnRetry(self): |
| 132 raw_results = [] |
| 133 |
| 134 result1 = base_test_result.BaseTestResult( |
| 135 'test.package.TestName1', base_test_result.ResultType.FAIL) |
| 136 run_results1 = base_test_result.TestRunResults() |
| 137 run_results1.AddResult(result1) |
| 138 raw_results.append(run_results1) |
| 139 |
| 140 result2 = base_test_result.BaseTestResult( |
| 141 'test.package.TestName1', base_test_result.ResultType.PASS) |
| 142 run_results2 = base_test_result.TestRunResults() |
| 143 run_results2.AddResult(result2) |
| 144 raw_results.append(run_results2) |
| 145 |
| 146 results_dict = json_results.GenerateResultsDict([raw_results]) |
| 147 self.assertEquals(['test.package.TestName1'], results_dict['all_tests']) |
| 148 |
| 149 # Check that there's only one iteration. |
| 150 self.assertIn('per_iteration_data', results_dict) |
| 151 iterations = results_dict['per_iteration_data'] |
| 152 self.assertEquals(1, len(iterations)) |
| 153 |
| 154 # Check that test.package.TestName1 is the only test in the iteration. |
| 155 self.assertEquals(1, len(iterations[0])) |
| 156 self.assertIn('test.package.TestName1', iterations[0]) |
| 157 |
| 158 # Check that there are two results for test.package.TestName1. |
| 159 actual_test_results = iterations[0]['test.package.TestName1'] |
| 160 self.assertEquals(2, len(actual_test_results)) |
| 161 |
| 162 # Check that the first result is a failure. |
| 163 self.assertIn('status', actual_test_results[0]) |
| 164 self.assertEquals('FAILURE', actual_test_results[0]['status']) |
| 165 |
| 166 # Check that the second result is a success. |
| 167 self.assertIn('status', actual_test_results[1]) |
| 168 self.assertEquals('SUCCESS', actual_test_results[1]['status']) |
| 169 |
131 | 170 |
132 if __name__ == '__main__': | 171 if __name__ == '__main__': |
133 unittest.main(verbosity=2) | 172 unittest.main(verbosity=2) |
134 | 173 |
OLD | NEW |