Skip to content

Include file and line attribute for junit report output format #4900

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

Closed
2 of 3 tasks
hanikesn opened this issue Aug 13, 2024 · 5 comments · Fixed by #4918
Closed
2 of 3 tasks

Include file and line attribute for junit report output format #4900

hanikesn opened this issue Aug 13, 2024 · 5 comments · Fixed by #4918
Assignees
Labels
area: output Related to issue output enhancement New feature or improvement

Comments

@hanikesn
Copy link

hanikesn commented Aug 13, 2024

Welcome

Your feature request related to a problem? Please describe

Various tools like action-junit-report rely on the file and line testcase attributes in order to report errors nicely inline the file.

file and line testcase attributse are also part of the Common JUnit XML Format:
https://github.com/testmoapp/junitxml?tab=readme-ov-file#complete-junit-xml-example

It'd be nice to include that information in golangci-lint reports as well.

Describe the solution you'd like

Include file and line testcase attributes like so:

<testsuites>
  <testsuite name="go/internal/pkg/set/set_test.go" tests="1" errors="0" failures="1">
    <testcase name="unused" classname="go/internal/pkg/set/set_test.go:15:6" file="go/internal/pkg/set/set_test.go" line="15">
      <failure message="go/internal/pkg/set/set_test.go:15:6: func `unused` is unused" type=""><![CDATA[: func `unused` is unused
Category: unused
File: go/internal/pkg/set/set_test.go
Line: 15
Details: func unused(t *testing.T) {]]></failure>
    </testcase>
  </testsuite>
</testsuites>

Describe alternatives you've considered

Parsing the file and line number from the classname is too brittle.

Additional context

No response

Supporter

@hanikesn hanikesn added the enhancement New feature or improvement label Aug 13, 2024
Copy link

boring-cyborg bot commented Aug 13, 2024

Hey, thank you for opening your first Issue ! 🙂 If you would like to contribute we have a guide for contributors.

@ldez ldez self-assigned this Aug 13, 2024
@ldez ldez added the area: output Related to issue output label Aug 13, 2024
@ldez
Copy link
Member

ldez commented Aug 13, 2024

Hello,

"Common JUnit XML Format" is not a specification but just an attempt to document the format.

There is no official specification for the JUnit XML file format and various tools generate and support different flavors of this format.

file and line are defined in the section "Complete JUnit XML example":

Not all elements are supported by all tools, and not all tools follow and understand the same conventions.

This can be a problem because those attributes are not a part of the "Basic JUnit XML structure".
If a tool validates the format with a strict approach, those fields will produce an error.

@ldez ldez added the no decision No decision to fix or not label Aug 13, 2024
@hanikesn
Copy link
Author

This can be a problem because those attributes are not a part of the "Basic JUnit XML structure".
If a tool validates the format with a strict approach, those fields will produce an error.

This could easily be avoided by making those opt-out/in.

@ldez
Copy link
Member

ldez commented Aug 16, 2024

It's not as easy as you think: the CLI flags don't allow adding options for only one format.

So there are 2 possibilities:

  • allow to add an option only with the configuration file
  • have a dedicated format

The first possibility will be confusing because this option will only work for one format (on 13 formats), so it is not the right possibility.

The second possibility seems better and it is near existing formats (colored-tab/tab, colored-line-number/line-number)

@hanikesn
Copy link
Author

hanikesn commented Sep 4, 2024

Nice! Thank you!

@ldez ldez removed the no decision No decision to fix or not label Sep 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: output Related to issue output enhancement New feature or improvement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants