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

Unified Diff: tools/telemetry/telemetry/unittest/output_formatter_test_runner_unittest.py

Issue 382433002: [telemetry] OutputFormatter for unit tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: tools/telemetry/telemetry/unittest/output_formatter_test_runner_unittest.py
diff --git a/tools/telemetry/telemetry/unittest/output_formatter_test_runner_unittest.py b/tools/telemetry/telemetry/unittest/output_formatter_test_runner_unittest.py
new file mode 100644
index 0000000000000000000000000000000000000000..5f4485f3f83c0bd3bd4c75e7f7f809e9da6a8bf3
--- /dev/null
+++ b/tools/telemetry/telemetry/unittest/output_formatter_test_runner_unittest.py
@@ -0,0 +1,54 @@
+# Copyright 2014 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import unittest
+
+from telemetry.unittest import output_formatter_test_runner
+
+
+class TestFoo(unittest.TestCase):
+ # Test method doesn't have test- prefix intentionally. This is so that
+ # run_test script won't run this test.
+ def RunPassingTest(self):
+ pass
+
+ def RunFailingTest(self):
+ self.fail('expected failure')
+
+
+class LoggingOutputFormatter(object):
+ def __init__(self):
+ self._call_log = []
+
+ @property
+ def call_log(self):
+ return tuple(self._call_log)
+
+ def __getattr__(self, name):
+ def wrapper(*_):
+ self._call_log.append(name)
+ return wrapper
+
+
+class OutputFormatterTestRunnerTest(unittest.TestCase):
+ def testAsdf(self):
+ suite = output_formatter_test_runner.OutputFormatterTestSuite()
+ suite.addTest(TestFoo(methodName='RunPassingTest'))
+ suite.addTest(TestFoo(methodName='RunFailingTest'))
+
+ output_formatter = LoggingOutputFormatter()
+ runner = output_formatter_test_runner.OutputFormatterTestRunner()
+ output_formatters = (output_formatter,)
+ result = runner.run(suite, output_formatters, 1, None)
+
+ self.assertEqual(len(result.successes), 1)
+ self.assertEqual(len(result.failures), 1)
+ self.assertEqual(len(result.failures_and_errors), 1)
+ expected = (
+ 'StartTestRun', 'StartTestSuite',
+ 'StartTest', 'Success', 'StopTest',
+ 'StartTest', 'Failure', 'StopTest',
+ 'StopTestSuite', 'StopTestRun',
+ )
+ self.assertEqual(output_formatter.call_log, expected)

Powered by Google App Engine
This is Rietveld 408576698