Skip to content

Commit 0fabf9f

Browse files
committed
Support messages directly under test in output.xml.
Fixes robotframework#3762.
1 parent 398e60b commit 0fabf9f

File tree

4 files changed

+38
-6
lines changed

4 files changed

+38
-6
lines changed

atest/robot/rebot/compatibility.robot

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,23 @@
11
*** Settings ***
2-
Documentation Test that current Rebot can process output.xml files generated by old Robot's.
3-
... Used output.xml files have been generated by running
2+
Documentation Test output.xml compatibility with old Robot versions and otherwise.
3+
...
4+
... RF version specific output.xml files have been generated by running
45
... ``./rundevel.py atest/testdata/misc/`` in appropriate version control tag.
5-
Test Template Run Rebot And Validate Statistics
66
Resource rebot_resource.robot
77

88
*** Test Cases ***
99
RF 3.2 compatibility
10-
rebot/output-3.2.2.xml 172 10
10+
Run Rebot And Validate Statistics rebot/output-3.2.2.xml 172 10
1111

1212
RF 4.0 compatibility
13-
rebot/output-4.0.xml 172 10
13+
Run Rebot And Validate Statistics rebot/output-4.0.xml 172 10
14+
15+
Message directly under test
16+
Run Rebot And Validate Statistics rebot/issue-3762.xml 1 0
17+
${tc} = Check Test Case test A
18+
Check Log Message ${tc.body[0]} Hi from test WARN
19+
Check Log Message ${tc.body[1].body[0]} Hi from keyword WARN
20+
Check Log Message ${tc.body[2]} Hi from test again INFO
1421

1522
*** Keywords ***
1623
Run Rebot And Validate Statistics

atest/testdata/rebot/issue-3762.xml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<robot>
3+
<suite source="suiteSource" name="suiteName">
4+
<test id="A" name="test A">
5+
<msg timestamp="20201116 08:29:45.100" level="WARN">Hi from test</msg>
6+
<kw name="log">
7+
<msg timestamp="20201116 08:29:45.100" level="WARN">Hi from keyword</msg>
8+
</kw>
9+
<status status="PASS" starttime="20201116 08:29:45.130" endtime="20201116 08:29:45.140"/>
10+
<msg timestamp="20201116 08:29:45.100" level="INFO">Hi from test again</msg>
11+
</test>
12+
</suite>
13+
</robot>

src/robot/result/xmlelementhandlers.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,8 @@ def get_child_handler(self, tag):
103103
class TestHandler(ElementHandler):
104104
tag = 'test'
105105
# 'tags' is for RF < 4 compatibility.
106-
children = frozenset(('doc', 'tags', 'tag', 'timeout', 'status', 'kw', 'if', 'for'))
106+
children = frozenset(('doc', 'tags', 'tag', 'timeout', 'status', 'kw', 'if', 'for',
107+
'msg'))
107108

108109
def start(self, elem, result):
109110
return result.tests.create(name=elem.get('name', ''))

utest/reporting/test_jsmodelbuilders.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,17 @@ def test_if(self):
186186
)
187187
self._verify_test(test, body=(exp_if, exp_else_if, exp_else))
188188

189+
def test_message_directly_under_test(self):
190+
test = TestSuite().tests.create()
191+
test.body.create_message('Hi from test')
192+
test.body.create_keyword().body.create_message('Hi from keyword')
193+
test.body.create_message('Hi from test again', 'WARN')
194+
exp_m1 = (8, None, 2, 'Hi from test')
195+
exp_kw = (0, '', '', '', '', '', '', '', (0, None, 0),
196+
((8, None, 2, 'Hi from keyword'),))
197+
exp_m3 = (8, None, 3, 'Hi from test again')
198+
self._verify_test(test, body=(exp_m1, exp_kw, exp_m3))
199+
189200
def _verify_status(self, model, status=0, start=None, elapsed=0):
190201
assert_equal(model, (status, start, elapsed))
191202

0 commit comments

Comments
 (0)