Skip to content

Commit fe1d899

Browse files
committed
Result model: Consider empty suite skipped, not passed.
This makes suite status easier to understand and explain: - If any fail -> FAIL - Else if any pass -> PASS - Else -> SKIP
1 parent d86d5c6 commit fe1d899

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

src/robot/result/model.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ def __init__(self, name='', doc='', metadata=None, source=None,
226226

227227
@property
228228
def passed(self):
229-
"""``True`` if no test has failed, ``False`` otherwise."""
229+
"""``True`` if no test has failed but some have passed, ``False`` otherwise."""
230230
return self.status == 'PASS'
231231

232232
@property
@@ -236,23 +236,22 @@ def failed(self):
236236

237237
@property
238238
def skipped(self):
239-
"""``True`` if all tests have been skipped, ``False`` otherwise."""
239+
"""``True`` if there are no passed or failed tests, ``False`` otherwise."""
240240
return self.status == 'SKIP'
241241

242242
@property
243243
def status(self):
244244
"""'PASS', 'FAIL' or 'SKIP' depending on test statuses.
245245
246246
- If any test has failed, status is 'FAIL'.
247-
- If no test has failed but some has passed, status is 'PASS'.
248-
- If all tests have been skipped, status is 'SKIP'.
247+
- If no test has failed but at least some test has passed, status is 'PASS'.
248+
- If there are no failed or passed tests, status is 'SKIP'. This covers both
249+
the case when all tests have been skipped and when there are no tests.
249250
"""
250251
stats = self.statistics.all # Local variable avoids recreating stats.
251252
if stats.failed:
252253
return 'FAIL'
253-
# TODO: Would 'SKIP' be better status if there are no executed tests?
254-
# Update also docstring above accordingly.
255-
if stats.total == 0 or stats.passed:
254+
if stats.passed:
256255
return 'PASS'
257256
return 'SKIP'
258257

utest/reporting/test_jsmodelbuilders.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ def _verify_status(self, model, status=0, start=None, elapsed=0):
168168
assert_equal(model, (status, start, elapsed))
169169

170170
def _verify_suite(self, suite, name='', doc='', metadata=(), source='',
171-
relsource='', status=1, message='', start=None, elapsed=0,
171+
relsource='', status=3, message='', start=None, elapsed=0,
172172
suites=(), tests=(), keywords=(), stats=(0, 0, 0, 0)):
173173
status = (status, start, elapsed, message) \
174174
if message else (status, start, elapsed)

utest/result/test_resultmodel.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ def _create_suite_with_tests(self):
4545

4646
class TestSuiteStatus(unittest.TestCase):
4747

48-
def test_suite_status_is_pass_by_default(self):
49-
assert_equal(TestSuite().status, 'PASS')
48+
def test_suite_status_is_skip_if_there_are_no_tests(self):
49+
assert_equal(TestSuite().status, 'SKIP')
5050

5151
def test_suite_status_is_fail_if_failed_test(self):
5252
suite = TestSuite()
@@ -67,7 +67,6 @@ def test_suite_status_is_pass_if_passed_and_skipped(self):
6767
suite = TestSuite()
6868
for i in range(5):
6969
suite.tests.create(status='PASS')
70-
for i in range(5):
7170
suite.tests.create(status='SKIP')
7271
assert_equal(suite.status, 'PASS')
7372

@@ -82,12 +81,14 @@ def test_suite_status_is_fail_if_failed_subsuite(self):
8281
suite = TestSuite()
8382
suite.suites.create().tests.create(status='FAIL')
8483
assert_equal(suite.status, 'FAIL')
84+
suite.tests.create(status='PASS')
85+
assert_equal(suite.status, 'FAIL')
8586

8687
def test_passed_failed_skipped_propertys(self):
8788
suite = TestSuite()
88-
assert_true(suite.passed)
89+
assert_false(suite.passed)
8990
assert_false(suite.failed)
90-
assert_false(suite.skipped)
91+
assert_true(suite.skipped)
9192
suite.tests.create(status='SKIP')
9293
assert_false(suite.passed)
9394
assert_false(suite.failed)

0 commit comments

Comments
 (0)