Skip to content

Commit d5a4833

Browse files
author
Matej Cotman
committed
fix(test): unifiy test for RF<4 and RF>=4
1 parent bfdb35f commit d5a4833

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

tests/utest/oxygen/test_oxygen_cli.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from subprocess import check_output, run
44
from unittest import TestCase
55
from unittest.mock import ANY, create_autospec, patch, Mock
6+
from xml.etree import ElementTree
67

78
from robot.running.model import TestSuite
89

@@ -54,10 +55,18 @@ def test_junit_works_on_cli(self):
5455
text=True,
5556
shell=True)
5657

57-
for expected in ('<stat pass="69" fail="3">Critical Tests</stat>',
58-
'<stat pass="69" fail="3">All Tests</stat>'):
59-
self.assertIn(expected, example.read_text())
60-
self.assertIn(expected, actual.read_text())
58+
example_xml = ElementTree.parse(example).getroot()
59+
actual_xml = ElementTree.parse(actual).getroot()
60+
61+
# RF<4 has multiple `stat` elements therefore we use the double slash
62+
# and a filter to single out the `stat` element with text "All Tests"
63+
all_tests_stat_block = './statistics/total//stat[.="All Tests"]'
64+
65+
example_stat = example_xml.find(all_tests_stat_block)
66+
actual_stat = actual_xml.find(all_tests_stat_block)
67+
68+
self.assertEqual(example_stat.get('pass'), actual_stat.get('pass'))
69+
self.assertEqual(example_stat.get('fail'), actual_stat.get('fail'))
6170

6271

6372
class TestOxygenCLI(TestCase):

0 commit comments

Comments
 (0)