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 file path to xunit reporter #4985

Merged
merged 3 commits into from Mar 12, 2024

Conversation

bmish
Copy link
Contributor

@bmish bmish commented May 15, 2023

Description of the Change

Expose test file path for each test case in the xunit reporter.

<testsuite name="Mocha Tests" tests="2" failures="0" errors="0" skipped="0" timestamp="Tue, 17 May 2022 21:10:34 GMT" time="0.001">
<testcase classname="Array #indexOf()" name="should return -1 when the value is not present" file="/path/to/test/array.js" time="0"/>
<testcase classname="Set #has()" name="should return false when the value is not present" file="/path/to/test/set.js" time="0"/>
</testsuite>

Alternate Designs

Why should this be in core?

The test file path was already added to other reporters in this PR:

It seems the file path can be added to each reporter as needed.

Benefits

  • Can be easier to find test file from file path instead of just test name, especially when overlapping/similar/identical test names are present, or in a large codebase
  • In particular, it can be easier for automated tooling to find the test file from the file path as opposed to the test name when performing test analysis or other scripting

Possible Drawbacks

  • Greater size / noise of output for people who don't need the file path
  • Let me know if there's any other reason not to do this

Applicable issues

None.

This should be part of a minor release as an enhancement.

I submitted this last year as #4885 but heard no response. I am recreating the same PR now after hearing interest in it in this comment: #4885 (comment)

Fixes #5112.

@github-actions
Copy link

This PR hasn't had any recent activity, and I'm labeling it stale. Remove the label or comment or this PR will be closed in 14 days. Thanks for contributing to Mocha!

@github-actions github-actions bot added the stale this has been inactive for a while... label Oct 30, 2023
@villelahdenvuo
Copy link
Contributor

I would like to see this merged, ideally with the Cypress fix I mentioned above...

bmish and others added 2 commits October 30, 2023 09:03
Co-authored-by: Ville Lahdenvuo <tuhoojabotti@gmail.com>
@github-actions github-actions bot removed the stale this has been inactive for a while... label Nov 1, 2023
Copy link
Member

@JoshuaKGoldberg JoshuaKGoldberg left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for pressing on this! 🙌

I think we can merge & consider any extra support for Cypress as a followup to discuss separately (is Cypress doing something odd, even wrong?).

@JoshuaKGoldberg JoshuaKGoldberg added the semver-minor implementation requires increase of "minor" version number; "features" label Mar 4, 2024
@JoshuaKGoldberg JoshuaKGoldberg changed the title Add file path to xunit reporter feat: add file path to xunit reporter Mar 4, 2024
@JoshuaKGoldberg JoshuaKGoldberg added the status: in triage a maintainer should (re-)triage (review) this issue label Mar 4, 2024
@JoshuaKGoldberg JoshuaKGoldberg removed the status: in triage a maintainer should (re-)triage (review) this issue label Mar 12, 2024
@voxpelli voxpelli merged commit efbb147 into mochajs:master Mar 12, 2024
5 of 6 checks passed
@voxpelli
Copy link
Member

Included in v10.4.0 🎉

@SophieDel
Copy link

Hi,
I am having trouble with the "file" field with the plugin xunit (laster version 3.1.4, dated from 2 months) in Jenkins. I didn't have find any solutions yet, and I stay in 10.3 for now for that reason. Am I missing anything...?
Thank you !

@JoshuaKGoldberg
Copy link
Member

JoshuaKGoldberg commented Apr 11, 2024

@SophieDel "having trouble" isn't enough details to go off of. Please file a new issue if you think this is a bug or missing feature in Mocha, or if not, see the Mocha Discord for asking for help in its #help channel. 🤎

@SophieDel
Copy link

SophieDel commented Apr 11, 2024

@JoshuaKGoldberg thank you ! I will explore further, and file a new issue if needed :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver-minor implementation requires increase of "minor" version number; "features"
Projects
None yet
Development

Successfully merging this pull request may close these issues.

🚀 Feature: Add file path to xunit reporter
6 participants