test-reporter icon indicating copy to clipboard operation
test-reporter copied to clipboard

Support for the PHPUnit dialect of JUnit

Open mbeccati opened this issue 10 months ago • 4 comments

PHPUnit uses nested <testsuite> elements, and the actual test cases are ignored in the current version of the reporter.

This is my first attempt at TypeScript, so apologies for any silly mistake.

Most likely it would be best to implement it as a separate parser, add more features, such as better error reporting, file links, etc.

As a first prototype, it seems to be working good enough for my current needs, e.g. https://github.com/mbeccati/php-latest-builds/runs/23625536886

mbeccati avatar Apr 09 '24 17:04 mbeccati

@mbeccati An interesting approach - when I needed to do this, I instead modified the PHPUnit test file to match the JUnit format:

# Change from
#
# <testsuites>
#   <testsuite name="" ...
#   ...
#   </testsuite>
# </testsuites>
#
# to
#
# <testsuites name=""
# ...
# </testsuites>

I think your approach is probably better though 🙂

One thing that I'm not sure "just works" in your version is the file annotations - I had to perform some regex to get this to work. See this: https://github.com/darshanrampatel/test-reporter/blob/e8fa95a4ce020faeb9a198f9b31bf4e6e200c2b9/src/parsers/phpunit-junit/phpunit-junit-parser.ts#L182-L196

(I apologise that it's not documented😅)

darshanrampatel avatar Apr 10 '24 13:04 darshanrampatel

@darshanrampatel nice! Feel free to borrow from this PR for your fork. That would indeed make for a better PR than this one. If you do, pls let me know. Id'be more than happy to give it a try

mbeccati avatar Apr 10 '24 13:04 mbeccati

This should be a new parser specific for PHPUnit format.

jozefizso avatar Jun 26 '24 11:06 jozefizso

@jozefizso I agree. I just wasn't sure exacty where to start with a new parser, or at least that's what I recall. It's bee a while ;-)

Are you suggesting I edit the PR creating a new parser? If so I think I'd need some guidance

mbeccati avatar Jun 26 '24 12:06 mbeccati