Is there a way to log stdout messages to xunit files?

199 views
Skip to first unread message

TJ S

unread,
Oct 31, 2014, 4:42:15 PM10/31/14
to robotframe...@googlegroups.com
Hi there,

I am currently trying to integrate my robot/SauceLabs tests into Jenkins, and as part of that, I was hoping to use Jenkins Sauce plugin to integrate the Sauce report directly into my jenkins job.

In order to accomplish this task, I need to use RF's --xunit command and pass that along to SauceLabs to process.  What they require within the XUnit file is a particular string holding a session ID.  They recommend that in order for my xunit file to have this, that I just print my string to stdout and the rest will take care of itself.  i think that Sauce is assuming that I am using nose though.  Sure enough, it works through nose...

test_workaround.py
class GenerateSauceXunitTestCase(unittest.TestCase):


   
def test_blah(self):
       
print('my session ID')

nosetests test_workaround.py --with-xunit

results in...

nosetests.xml
<?xml version="1.0" encoding="UTF-8"?>
<testsuite name="nosetests" tests="1" errors="0" failures="0" skip="0">
   
<testcase classname="test_workaround.GenerateSauceXunitTestCase" name="test_output" time="0.000">
       
<system-out><![CDATA[my session ID]]></system-out>
   
</testcase>
</testsuite>

I have attempted everything under the sun to get this particular string to show up in the xunit file produced by RF, including the recommendations discussed here: http://stackoverflow.com/questions/5540784/how-can-a-test-called-by-robot-framework-return-information-to-the-console.  But so far, I have not had any luck.

Is there any current way to achieve this result?  If not, is this a good feature request?

Pekka Klärck

unread,
Nov 3, 2014, 6:55:07 PM11/3/14
to TJ S, robotframework-users
Hi,

Robot's xunit outputs don't support this. At least in theory an option
could be added to include everything logged by keywords inside
<system-out/>, but I'm afraid the result would be pretty messed up
when you have more keywords that log something. Another problem is
that there's no real standard for xunit xml format and thus it's hard
to tell how different tools handle elements like <system-out/>. If
this functionality can be implemented in a generic manner, I don't see
why we wouldn't accept a pull request. Personally I'd investigate is
there any other way to pass the session ID, though.

Cheers,
.peke
> --
> You received this message because you are subscribed to the Google Groups
> "robotframework-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to robotframework-u...@googlegroups.com.
> To post to this group, send email to robotframe...@googlegroups.com.
> Visit this group at http://groups.google.com/group/robotframework-users.
> For more options, visit https://groups.google.com/d/optout.



--
Agile Tester/Developer/Consultant :: http://eliga.fi
Lead Developer of Robot Framework :: http://robotframework.org
Reply all
Reply to author
Forward
Message has been deleted
0 new messages