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

Side by Side Diff: build/android/pylib/base/base_test_result_unittest.py

Issue 12544033: [Android] Rewrite base test result classes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 9 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 # Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4
5 """Unittests for TestRunResults."""
6
7 import unittest
8
9 from base_test_result import BaseTestResult
10 from base_test_result import TestRunResults
11 from base_test_result import ResultType
12
13
14 class TestTestRunResults(unittest.TestCase):
15 def setUp(self):
16 self.p1 = BaseTestResult('p1', ResultType.PASS, log='pass1')
17 other_p1 = BaseTestResult('p1', ResultType.PASS)
18 self.p2 = BaseTestResult('p2', ResultType.PASS)
19 self.f1 = BaseTestResult('f1', ResultType.FAIL, log='failure1')
20 self.c1 = BaseTestResult('c1', ResultType.CRASH, log='crash1')
21 self.u1 = BaseTestResult('u1', ResultType.UNKNOWN)
22 self.tr = TestRunResults()
23 self.tr.AddResult(self.p1)
24 self.tr.AddResult(other_p1)
25 self.tr.AddResult(self.p2)
26 self.tr.AddResults(set([self.f1, self.c1, self.u1]))
27
28 def testGetAll(self):
29 self.assertFalse(
30 self.tr.GetAll().symmetric_difference(
31 [self.p1, self.p2, self.f1, self.c1, self.u1]))
32
33 def testGetPass(self):
34 self.assertFalse(self.tr.GetPass().symmetric_difference(
35 [self.p1, self.p2]))
36
37 def testGetNotPass(self):
38 self.assertFalse(self.tr.GetNotPass().symmetric_difference(
39 [self.f1, self.c1, self.u1]))
40
41 def testGetAddTestRunResults(self):
42 tr2 = TestRunResults()
43 other_p1 = BaseTestResult('p1', ResultType.PASS)
44 f2 = BaseTestResult('f2', ResultType.FAIL)
45 tr2.AddResult(other_p1)
46 tr2.AddResult(f2)
47 tr2.AddTestRunResults(self.tr)
48 self.assertFalse(
49 tr2.GetAll().symmetric_difference(
50 [self.p1, self.p2, self.f1, self.c1, self.u1, f2]))
51
52 def testGetLogs(self):
53 log_print = ('[FAIL] f1:\n'
54 'failure1\n'
55 '[CRASH] c1:\n'
56 'crash1\n'
57 '[UNKNOWN] u1:\n')
58 self.assertEqual(self.tr.GetLogs(), log_print)
59
60 def testGetShortForm(self):
61 short_print = ('ALL: 5 PASS: 2 FAIL: 1 '
62 'CRASH: 1 TIMEOUT: 0 UNKNOWN: 1 ')
63 self.assertEqual(self.tr.GetShortForm(), short_print)
64
65 def testGetLongForm(self):
66 long_print = ('ALL (5 tests)\n'
67 'PASS (2 tests)\n'
68 'FAIL (1 tests): [f1]\n'
69 'CRASH (1 tests): [c1]\n'
70 'TIMEOUT (0 tests): []\n'
71 'UNKNOWN (1 tests): [u1]')
72 self.assertEqual(self.tr.GetLongForm(), long_print)
73
74 def testRunPassed(self):
75 self.assertFalse(self.tr.DidRunPass())
76 tr2 = TestRunResults()
77 self.assertTrue(tr2.DidRunPass())
78
79
80 if __name__ == '__main__':
81 unittest.main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698