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

Include test output for successful tests in junitfile #118

Open
arthurvaverko-kaltura opened this issue May 17, 2020 · 8 comments · May be fixed by #327 or #383
Open

Include test output for successful tests in junitfile #118

arthurvaverko-kaltura opened this issue May 17, 2020 · 8 comments · May be fixed by #327 or #383
Labels
enhancement New feature or request

Comments

@arthurvaverko-kaltura
Copy link

arthurvaverko-kaltura commented May 17, 2020

My tests print out logs using t.Log(..)
is there any way to display these logs inside a junit output ?

@dnephin
Copy link
Member

dnephin commented May 17, 2020

Thank you for your interest in gotestsum! The log output for failed and skipped tests is included in the report (source), but gotestsum drops the output of tests once the test passes, so it is not available to the report. The rational is that some tests suites may produce a lot of output, and I didn't want to store all of it in memory.

It is possible that a new flag could be added to preserve all of the output, including that of passed tests.

Are you looking for only the failure output, or output for passed tests as well?

@arthurvaverko-kaltura
Copy link
Author

Looking for all output ..
If you can point me to the correct location I could do a pull request ..

@dnephin dnephin added the enhancement New feature or request label May 17, 2020
@dnephin
Copy link
Member

dnephin commented May 17, 2020

https://github.com/gotestyourself/gotestsum/blob/master/testjson/execution.go#L275-L276 is the line, but I think there may still be other parts of the code that assume this output is removed. If I remember correctly PrintSummary in testjson/summary.go may need to be changed.

https://github.com/gotestyourself/gotestsum/blob/6cbcac1/internal/junitxml/report.go#L173-L176 will also need to be changed to include the output in the report. There is no field for that right now on the struct. Do you know what the xml tag name should be?

@arthurvaverko-kaltura
Copy link
Author

I don't but I'll try to look into it soon ...

@dnephin dnephin changed the title Add test logs to junit output Include test output for successful tests in junitfile Jun 17, 2020
@sodul
Copy link

sodul commented Jul 2, 2020

@arthurvaverko you could use the --jsonfile output to preserve all the output, if you just need it for reference just in case.

Adding a flag to preserve the output for all test could be nice, but we really prefer the current behavior.

@alexxed
Copy link

alexxed commented Apr 25, 2023

I opened a Pr for this #327

@dnephin
Copy link
Member

dnephin commented Nov 4, 2023

#380 was opened recently and sounds like the same ask. I think maybe we should close one of these issues as a duplicate. The discussion in that issue made me realize it's not clear where system-out is supposed to go.

It sounds like #327 and others in these issues are expecting it as a child tag ex:

<testcase>
   <system-out></system-out>
</testcase>

If I look at all the top hits on google (https://github.com/windyroad/JUnit-Schema/blob/master/JUnit.xsd, https://github.com/testmoapp/junitxml, https://stackoverflow.com/a/9410271/444646) they put system-out as a sibling to testcase (not a child), so the output would be associated with the testsuite, not the testcase.

Does anyone have an example of the schema that puts system-out under test-case ?

Edit: Ah https://github.com/testmoapp/junitxml does actually show it as both. So I guess that's where it comes from.

@rkeithhill-keysight
Copy link

Ah, <system-out> is what go-junit-report uses to capture stdout for passed tests:

<testcase name="TestIsAliveSuite" classname="internal/foo" time="0.000">
	<system-out><![CDATA[    suite.go:229: warning: no tests to run]]></system-out>
</testcase>

@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
5 participants