Skip to content
This repository was archived by the owner on Jan 1, 2026. It is now read-only.

Commit 83c00d0

Browse files
authored
Always set classname and name XML attributes for error test cases (#6)
1 parent 62cf03e commit 83c00d0

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

cppcheck_junit.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,9 @@ def generate_test_suite(errors):
123123
for file_name, errors in errors.items():
124124
test_case = ElementTree.SubElement(test_suite,
125125
'testcase',
126-
name=os.path.relpath(file_name) if file_name else '',
127-
classname='',
126+
name=os.path.relpath(
127+
file_name) if file_name else 'Cppcheck error',
128+
classname='Cppcheck error',
128129
time=str(1))
129130
for error in errors:
130131
ElementTree.SubElement(test_case,
@@ -153,7 +154,7 @@ def generate_single_success_test_suite():
153154
ElementTree.SubElement(test_suite,
154155
'testcase',
155156
name='Cppcheck success',
156-
classname='',
157+
classname='Cppcheck success',
157158
time=str(1))
158159
return ElementTree.ElementTree(test_suite)
159160

test.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,8 @@ def test_missing_file(self): # type: () -> None
168168
self.assertTrue(required_attribute in testsuite_element.attrib.keys())
169169

170170
testcase_element = testsuite_element.find('testcase')
171-
self.assertEqual(testcase_element.get('name'), '')
171+
self.assertEqual(testcase_element.get('name'), 'Cppcheck error')
172+
self.assertEqual(testcase_element.get('classname'), 'Cppcheck error')
172173
# Check that test_case is compliant with the spec
173174
for required_attribute in self.junit_testcase_attributes:
174175
self.assertTrue(required_attribute in testcase_element.attrib.keys())
@@ -207,6 +208,7 @@ def test(self): # type: () -> None
207208

208209
testcase_element = testsuite_element.find('testcase')
209210
self.assertEqual(testcase_element.get('name'), 'Cppcheck success')
211+
self.assertEqual(testcase_element.get('classname'), 'Cppcheck success')
210212
# Check that test_case is compliant with the spec
211213
for required_attribute in self.junit_testcase_attributes:
212214
self.assertTrue(required_attribute in testcase_element.attrib.keys())

0 commit comments

Comments
 (0)