Skip to content

Conversation

maltemorgenstern
Copy link
Contributor

Description:

This merge request adds junit as a new report format.

As described in #404 junit reports can be integrated with CI/CD systems as test reports for easier visualisation in the browser and merge requests. I tested these changes with the GitLab Unit Test Reports feature.

That's why the generated junit format follows the GitLab requirements. In general it is based on the IBM junit format with some additional and missing attributes (some of them could be added in the future if needed).

Here is an example of the GitLab integration:

Click to expand!

image

image

Links/Docs:

This MR closes #404

Unrelated change

I also added testdata/expected/report/*.got.* to the .gitignore because they should not be commited to the repo.

Checklist:

  • Does your PR pass tests?
  • Have you written new tests for your changes?
  • Have you lint your code locally prior to submission?

@maltemorgenstern
Copy link
Contributor Author

Hey @zricethezav, this PR is ready for review 🚀
Thanks 😃

@zricethezav
Copy link
Collaborator

@maltemorgenstern would you mind updating this? Also since I do not have any junit experience would you mind keeping an eye on this moving forward when it gets merged in?

@maltemorgenstern
Copy link
Contributor Author

Hey @zricethezav

Would you mind updating this?

Sure - I will take a look at this the next few days and solve the conflicts!

Also since I do not have any junit experience would you mind keeping an eye on this moving forward when it gets merged in?

I must admit that I am not really familiar with the junit format either - I just looked into it for a bit and created this solution based on other junit report implementations/references.

But I should definitely be able to take a look at future PRs and test them with the GitLab integration.

@maltemorgenstern
Copy link
Contributor Author

@zricethezav this PR is now up-to-date again and ready for review/merge.

@strowi
Copy link

strowi commented Feb 13, 2023

Would really love to see junit support to integrate with CI and have a standardized format. ;)

@maltemorgenstern
Copy link
Contributor Author

Hey @zricethezav,
this pull request is ready for review. If there are any additional checks to be done please let me know!

@squatchBKLN
Copy link

been keeping an eye on the PR, as it seems really useful. it has been open for quite some time... any plans on merging it?

@zricethezav zricethezav merged commit 0dbdde8 into gitleaks:master Jun 13, 2023

for _, test := range tests {
// create tmp file using os.TempDir()
tmpfile, err := os.Create(filepath.Join(tmpPath, test.testReportName+".xml"))
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link

@lesaux lesaux Jun 13, 2023

Choose a reason for hiding this comment

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

can confirm tmpPath is not declared. my pipelines broke today.

Copy link
Collaborator

Choose a reason for hiding this comment

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

fix't in b1d59bf

alayne222 pushed a commit to alayne222/gitleaks that referenced this pull request May 28, 2025
* add junit report format

* add fingerprint to expected test result to fix tests

* fix expected junit test report
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.

Junit-Support
6 participants