Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add junit formatter #2121

Merged
merged 21 commits into from
Nov 24, 2022
Merged

Conversation

ricalbuquerque
Copy link
Contributor

@ricalbuquerque ricalbuquerque commented Aug 29, 2022

🤔 What's changed?

  • Added JUnit formatter

⚡️ What's your motivation?

Needed to get proper reporting in Azure Pipelines so had to develop a JUnit formatter that would not treat each step as a different test. After testing and started to use it I decided to make it available for the community,

🏷️ What kind of change is this?

  • ⚡ New feature (non-breaking change which adds new behaviour)

♻️ Anything particular you want feedback on?

  • Feel free to suggest any change or possible improvement!

📋 Checklist:

  • I agree to respect and uphold the Cucumber Community Code of Conduct
  • I've changed the behaviour of the code
    • I have added/updated tests to cover my changes.
  • My change requires a change to the documentation.
    • I have updated the documentation accordingly.
  • Users should know about my change
    • I have added an entry to the "Unreleased" section of the CHANGELOG, linking to this pull request.

This text was originally generated from a template, then edited by hand. You can modify the template here.

@coveralls
Copy link

coveralls commented Aug 29, 2022

Coverage Status

Coverage increased (+0.06%) to 98.317% when pulling effb22a on ricalbuquerque:feat/junit-formatter into efd77e3 on cucumber:main.

@ricalbuquerque ricalbuquerque marked this pull request as ready for review August 29, 2022 15:24
@davidjgoss
Copy link
Contributor

davidjgoss commented Aug 30, 2022

Thanks for raising this @ricalbuquerque, we do indeed need a JUnit formatter and this looks like a good implementation at first glance.

There's a broader effort in cucumber/common#871 to have a JUnit formatter for all Cucumber implementations that behave the same (share a test suite etc), so I'm going to bring this up there and see if it could be a vehicle to get that piece moving a bit in the right direction, and I'll probably come back with some detailed review comments soon.

@ricalbuquerque
Copy link
Contributor Author

Thank you @davidjgoss. I don't mean to interfere with any plans for a new formatter. I did try a few formatters (some of them seem to be a bit old) and none would do what I was expecting to (treating scenarios as testcases) so this was my motivation.
I did see that issue on the common repo but since it seemed to be a bit blocked I decided to implement a version of it in javascript since I don't have that much experience in Go.
Feel free to suggest any improvements you would like to see!

@davidjgoss
Copy link
Contributor

@ricalbuquerque not an interference at all, I think this could help move it forward. I don't think there will be a single implementation in Go, that model didn't work great in practise for other components. More like, a shared set of tests and then native implementations in JavaScript, Java, Ruby etc that all pass those same tests. So this is definitely in line with that.

Copy link
Contributor

@mpkorstanje mpkorstanje left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at the test cases, I feel there may be a lot of fidelity missing. I can't provide concrete examples right now but contrast with the Cucumber JVM test cases:

https://github.com/cucumber/cucumber-jvm/blob/main/cucumber-core/src/test/java/io/cucumber/core/plugin/JUnitFormatterTest.java

And so it might be good to compare against the XSD.

https://github.com/cucumber/cucumber-jvm/blob/main/cucumber-core/src/test/resources/io/cucumber/core/plugin/surefire-test-report-3.0.xsd

Copy link
Contributor

@davidjgoss davidjgoss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Following on from previous comments, just calling out things that are different from the style seen in cucumber-jvm which I think we should align with:

I'm happy to jump in and help out with any of this if you'd like, just let me know. Thanks again for putting this together.

src/formatter/junit_formatter_spec.ts Show resolved Hide resolved
@tim-yao
Copy link
Member

tim-yao commented Oct 31, 2022

We need this as CircleCI will stop support for JSON format in 20 days. Here is the announcement: https://discuss.circleci.com/t/cucumber-test-results-format-deprecation/45776

Starting November 20th, all projects using the Cucumber test runner must store test results using the junit format.

This PR is the only way to continue using cucumber with CircleCI. The existing JUnit formatted plugin is not working with new cucumber-js versions:
mvtm-dn/cucumber-junit-formatter#10

@davidjgoss
Copy link
Contributor

@ricalbuquerque are you happy for me to make some of the changes discussed above so we can get this in?

Copy link
Contributor

@mpkorstanje mpkorstanje left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Spotted a few complicated problems.

@davidjgoss davidjgoss self-assigned this Nov 16, 2022
@davidjgoss
Copy link
Contributor

@mpkorstanje I've made some updates to bring this pretty much in line with what the cucumber-jvm one does, and added more tests. Would you mind taking another look before I merge?

Copy link
Contributor

@davidjgoss davidjgoss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Huge thanks @ricalbuquerque for contributing this!

@davidjgoss davidjgoss merged commit 70cc0fd into cucumber:main Nov 24, 2022
@aslakhellesoy
Copy link
Contributor

Hi @ricalbuquerque,

Thanks for your making your first contribution to Cucumber, and welcome to the Cucumber committers team! You can now push directly to this repo and all other repos under the cucumber organization! 🍾

In return for this generous offer we hope you will:

  • ✅ Continue to use branches and pull requests. When someone on the core team approves a pull request (yours or someone else's), you're welcome to merge it yourself.
  • 💚 Commit to setting a good example by following and upholding our code of conduct in your interactions with other collaborators and users.
  • 💬 Join the community Slack channel to meet the rest of the team and make yourself at home.
  • ℹ️ Don't feel obliged to help, just do what you can if you have the time and the energy.
  • 🙋 Ask if you need anything. We're looking for feedback about how to make the project more welcoming, so please tell us!

On behalf of the Cucumber core team,
Aslak Hellesøy
Creator of Cucumber

@mpkorstanje
Copy link
Contributor

@mpkorstanje I've made some updates to bring this pretty much in line with what the cucumber-jvm one does, and added more tests. Would you mind taking another look before I merge?

Looks good!

@davidjgoss
Copy link
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants