unittest-xml-reporting icon indicating copy to clipboard operation
unittest-xml-reporting copied to clipboard

Added the ability to set set_attribute

Open klookAppTest opened this issue 5 years ago • 1 comments

I need to customize the attribute in the case

For example

import unittest
import xmlrunner
from xmlrunner.result import set_attribute


class TestSequenceFunctions(unittest.TestCase):

    def test_sample(self):
        set_attribute({"jira": "0001", "case_id": "1001"})


if __name__ == '__main__':
    with open('./results.xml', 'wb') as output:
        unittest.main(
            testRunner=xmlrunner.XMLTestRunner(output=output),
            failfast=False, buffer=False, catchbreak=False)

result.xml

<?xml version="1.0" encoding="UTF-8"?>
<testsuites>
	<testsuite errors="0" failures="0" file=".py" name="TestSequenceFunctions-20200827100320" skipped="0" tests="1" time="0.007" timestamp="2020-08-27T10:03:20">
		<testcase case_id="1001" classname="TestSequenceFunctions" file="best_sample.py" jira="0001" line="9" name="test_sample" time="0.007" timestamp="2020-08-27T10:03:20">
			<system-out>
<![CDATA[{"jira": "0001", "case_id": "1001"}]]>			</system-out>
		</testcase>
	</testsuite>
</testsuites>

klookAppTest avatar Aug 27 '20 02:08 klookAppTest

I need to customize the attribute in the case

@klookAppTest , can you please go through the 5 whys (https://en.wikipedia.org/wiki/Five_whys) exercise and explain better what you are trying to do?

if all you need is print something on stdout, you can already do that.

dnozay avatar Nov 16 '20 16:11 dnozay