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

junitxml: include full output in system-out field #380

Open
epot opened this issue Nov 2, 2023 · 7 comments · May be fixed by #383
Open

junitxml: include full output in system-out field #380

epot opened this issue Nov 2, 2023 · 7 comments · May be fixed by #383
Labels
enhancement New feature or request

Comments

@epot
Copy link

epot commented Nov 2, 2023

Unless I am mistaken, junit supports having system-out under testcase, to capture a failing test standard output. Unfortunately, this does not seem to be supported by this tool. Is there any plan to do so? It would allow feeding other products like Datadog CI visibility for instance.

@dnephin
Copy link
Member

dnephin commented Nov 2, 2023

Hello, failing test output is captured under testcase.failure , you can see an example here: https://github.com/gotestyourself/gotestsum/blob/main/internal/junitxml/testdata/junitxml-report.golden#L60

This seems to work for most CI systems. Do you have an example of a junit.xml file that isn't working?

@epot
Copy link
Author

epot commented Nov 3, 2023

Ah thanks for this example I did not see it. I have exactly the same layout on my side. My problem is that Datadog CI system expects the standard output to be in system-out. What is under failure is completely put under the "error" area there, whereas I would like a "short" error message there and then logs individually searchable there. You can imagine how ugly the screenshot below can get where it's an integration test and there is a lot of output :).

Screenshot 2023-11-03 at 6 46 12 AM

Maybe I misunderstand the junit standard, but I thought that system-out and system-err were intended to have the standard output. Do you think we could have an option or change the gotestsum default behavior? Or should I look for an alternative?

@dnephin
Copy link
Member

dnephin commented Nov 4, 2023

Unfortunately there is no real official standard. It seems every system does something a little different. There are a few flags to modify the output in the junit.xml to accomodate different systems

      --junitfile-project-name string               name of the project used in the junit.xml file
      --junitfile-testcase-classname field-format   format the testcase classname field as: full, relative, short (default full)
      --junitfile-testsuite-name field-format       format the testsuite name field as: full, relative, short (default full)

I think to accomplish what you describe here we'll need to wait for this Go proposal golang/go#62728 to be accepted and implemented. With that change we could add a flag to send only the OutputType: error output to the failure field, and send the full log to system-out.

It's possible to send everything to system-out now, if you're interested in submitting a PR to do that, but it wouldn't be anything new. It would be the same text as the failure tag.

Issue #118 is also related I guess. It wasn't said explicitly in that issue, but I'm assuming they were expecting the full output in system-out as well.

I'll re-title this issue to clarify the feature request.

@dnephin dnephin added the enhancement New feature or request label Nov 4, 2023
@dnephin dnephin changed the title Capture tests output in junit file junitxml: include full output in system-out field Nov 4, 2023
@dnephin
Copy link
Member

dnephin commented Nov 4, 2023

Looking at https://github.com/windyroad/JUnit-Schema/blob/cfa434d4b8e102a8f55b8727b552a0063ee9044e/JUnit.xsd#L150 I'm still a bit confused about how this is supposed to work.

That system-out tag is at the same level as testcase, meaning it's a sibling to the test case, not a child of it. That makes it look like the system-out is relevant to the entire test suite, not a particular testcase.

Does Datadog CI publish the schema they expect?

@dnephin
Copy link
Member

dnephin commented Nov 4, 2023

I just noticed that https://github.com/testmoapp/junitxml does actually show it as both a sibling and a child. So I guess that's where it comes from.

@rkeithhill-keysight
Copy link

We have this problem as well. We use Jenkins and BlueOcean's CI/CD pipeline view. If we use go-junit-report we get stdout displayed in the Tests view:

image

I haven't found a way to get this stdout into the --junitfile XML file so it shows up in Jenkins/BlueOcean.

@epot
Copy link
Author

epot commented Nov 9, 2023

@dnephin sorry for the latency, I wanted to circle back with a few Datadog folks and do more tests.
Actually I was wrong above: whatever is under testcase.failure actually appears as logs in Datadog. It's just a little weird because it also appears in the test failure, which can be pretty ugly when the test logged a lot of lines (hundreds in some cases).
In any case I am interested in putting into a child of testcase the system-out of the test. Do you confirm you would be ok if I submit a PR for that?

@dnephin dnephin linked a pull request Nov 18, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants