weiwei / junitparser

Parses JUnit/xUnit Result XML files with ease
https://junitparser.readthedocs.io
Other
120 stars 52 forks source link

"bulk add" does not work #126

Closed Stefanhg closed 9 months ago

Stefanhg commented 9 months ago

Hello, I was doing some testing where i was creating a Junit file and I came across a documented feature that was not working.

The source code does not handle the documented support for appending a list of testcaes:

#Bulk add cases to suite
case3 = TestCase('case3')
case4 = TestCase('case4')
suite.add_testcases([case3, case4])

The add_testcase method only expects a single type and not multiple types. It could be a good idea to add some types to the elements, this makes it easier to catch these erros while programming:

def add_testcase(self, testcase: Element | list):
    """Add a testcase *testcase* to the testsuite."""
    self.append(testcase)
    self.update_statistics()

I assume it is just a 3-line fix in self.append. I don't have git set up on my work-machine so I can't add a fix now.

weiwei commented 9 months ago

There are two methods: add_testcase and add_testcases, the latter accepts a list. But yes, adding types should be useful.

Stefanhg commented 9 months ago

@weiwei Ah yeah I can see that. Did not notice there being two methods for it.