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

Allow customization option for junit formatter #2265

Closed
Tallyb opened this issue Mar 22, 2023 · 7 comments · Fixed by #2286
Closed

Allow customization option for junit formatter #2265

Tallyb opened this issue Mar 22, 2023 · 7 comments · Fixed by #2286
Labels
good first issue Good for newcomers ✅ accepted The core team has agreed that it is a good idea to fix this ⚡ enhancement Request for new functionality

Comments

@Tallyb
Copy link

Tallyb commented Mar 22, 2023

🤔 What's the problem you're trying to solve?

currently all reports generated with cucumberjs junit formatter bear the name 'cucumber-js'. It would be great to be able to customize it via format options and cli param

✨ What's your proposed solution?

format option with test suite name.

⛏ Have you considered any alternatives or workarounds?

open for suggestions...

📚 Any additional context?

On a side note, it is not really clear how to configure options in a cucumber.mjs file when there are multiple formtters defined.

format: [
  'json:e2e/reports/cucumber-report.json',
  'junit:e2e/reports/cucumber-report.xml',
  'summary'
];

Adding options to the json formatter and to the junit in a single formatOptions: {} entry is cumbersome. Probably best to make each formatter an object. 

format: [
  {type: json, output: 'json:e2e/reports/cucumber-report.json', options: {x: 1, y: false}},
  { type: 'junit', output:  'e2e/reports/cucumber-report.xml', options: {x: 1, z: true}},
  'summary'
];
@davidjgoss
Copy link
Contributor

Adding options to the json formatter and to the junit in a single formatOptions: {} entry is cumbersome

I tend to agree, and I like your suggestion, though that would potentially end up being a significant change so let's make another issue for that.

@davidjgoss
Copy link
Contributor

To enable this with the current options structure we'd do something like:

{
  "formatOptions": {
    "junit": {
      "suiteName": "my test suite"
    }
  }
}

@davidjgoss davidjgoss added ✅ accepted The core team has agreed that it is a good idea to fix this ⚡ enhancement Request for new functionality labels Mar 23, 2023
@davidjgoss
Copy link
Contributor

The line in question is here https://github.com/cucumber/cucumber-js/blob/main/src/formatter/junit_formatter.ts#L245. The options being passed into the constructor has a parsedArgvOptions prop which should be the format options from the user.

@davidjgoss davidjgoss added the good first issue Good for newcomers label Mar 25, 2023
@Sam-ScottLogic
Copy link

May I work on this? This is my first time contributing so may have a few questions along the way!

@davidjgoss
Copy link
Contributor

Sure @Sam-ScottLogic, go for it! Feel free to ask questions here, or join #committers-js in the Slack https://cucumber.io/docs/community/get-in-touch/

@astocker-scottlogic
Copy link
Contributor

@Sam-ScottLogic Hi am I okay to take a look into this?

@Sam-ScottLogic
Copy link

@astocker-scottlogic Yes!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers ✅ accepted The core team has agreed that it is a good idea to fix this ⚡ enhancement Request for new functionality
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants