-
Notifications
You must be signed in to change notification settings - Fork 136
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
How to integrate test results into jenkins #209
Comments
Hum now by using JUnit instead of CUnit report type, I got a bunch of errors of this kind:
for attributes timestamp, line and file, which seems to indicate that I'm back to the errors described in #201 |
I've somehow worked around the problem by using the Custom tool Report type of the xUnit plugin, with the following custom stylesheet: <?xml version='1.0'?>
<!-- This stylesheet allows to filter out the attributes which
python-xmlrunner but which are not supported by the junkins xUnit plugin
(because its author broke the retro-compatibility by removing them).
So it'll remove the file, line and timestamp attributes of all the testcase
tags. -->
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:output method="xml" indent="yes" />
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*" />
</xsl:copy>
</xsl:template>
<xsl:template match="//testcase">
<testcase>
<xsl:for-each select="@*[name() != 'line' and name() != 'file' and name() != 'timestamp']|child::*">
<xsl:copy-of select="."/>
</xsl:for-each>
</testcase>
</xsl:template>
</xsl:stylesheet> Yet I think that this should be fixed in either unittest-xml-reporting or in the xUnit plugin. |
@ncarrier Any way to add failed/skipped tests support? For me the "failed" and "skipped" columns in the report show as 0, even if there were such tests. |
@pbudzon Hello
On jenkins, I only tested failed tests (which work). FWIW I changed my method a little bit. import xmlrunner
import unittest
import lxml.etree as etree
import io
import os
...
if __name__ == '__main__':
out = io.BytesIO()
# run the tests while temporarily storing them in a memory backed file-like
# object
unittest.main(testRunner=xmlrunner.XMLTestRunner(output=out),
failfast=False, buffer=False, catchbreak=False, exit=False)
# transform the XML generated to remove the attributes breaking the
# compatibility with the jenkins xUnit plugin
out_xml = etree.XML(out.getvalue())
xslt = etree.parse(os.path.join(DIRNAME, "xmlunittest.xsl"))
transform = etree.XSLT(xslt)
out_processed = transform(out_xml)
# we're good, we can echo the final XML to stdout
print(etree.tostring(out_processed, pretty_print=True).decode("utf8")) |
@ncarrier Thanks for this. We actually decided to move away from xunit completely, as it seems the junit parser that's built-in in Jenkins parses the output from xmlrunner without issues, out of the box. |
Ha, ok, glad to read you've found a solution. |
- see #209; add a utility function for XSLT transformation. - minor doc fixes. - fix incorrect version, I called out xunit plugin 2.2.4 earlier and I must not have looked at the version properly.
- see #209; add a utility function for XSLT transformation. - minor doc fixes. - fix incorrect version, I called out xunit plugin 2.2.4 earlier and I must not have looked at the version properly.
- see #209; add a utility function for XSLT transformation. - minor doc fixes. - fix incorrect version, I called out xunit plugin 2.2.4 earlier and I must not have looked at the version properly.
Here is a XSL you can use similar to the one @ncarrier posted earlier.
You'd need to use either I've amended the readme with the steps which I am going to repeat here:
Transform the results removing extra attributes.
There is a PR where there is a discussion to either add back the fields as optional on
To go back to this earlier comment; I don't plan on dropping the attributes because they provide good debugging information; testsuites are collection of testcases, and testcases can be defined in different |
Hello, But for the
I understand and I think you're right, but is there a way to have these pieces of information correctly used by the xUnit plugin? For example by applying another XSLT transform and maybe, using another report type? |
You could add support directly in e.g. jenkinsci/xunit-plugin@2ccffb7#diff-1f96023169ac3d7dfb33b8a32c703bea |
Hello,
I'm trying to integrate the xml output of unit tests into jenkins, using the xUnit plugin.
Software versions are:
The relevant configuration is the following.
At the end of the build, I have the following log lines:
Yet the xml files contains:
Can it be related to issue #201 ?
Is there a way I can get this to work?
The text was updated successfully, but these errors were encountered: