Welcome to our new forum
All users of the legacy CODESYS Forums, please create a new account at account.codesys.com. But make sure to use the same E-Mail address as in the old Forum. Then your posts will be matched.
Close
In this thread user Goof van de Weg mentioned that they had created a python script to convert exported Test Manager reports into a Junit format for Jenkins to recognize. As I don't believe he is active anymore I have created my own and wish to share it to those who would like to do the same.
Modify as you see fit - mine assumes that the test FBs are named FB_{FBNAME)_UNITTESTS and names the cases by each step of a multitest.
Install untangle, dateutil and junit_xml from pip or where ever you get your modules from
importuntangleimportsysfromdateutilimportparserfromjunit_xmlimportTestSuite,TestCase
\# Get time taken to execute test in seconds for JUnit reportdefgetTimeTaken(startTime,endTime):  st=parser.parse(startTime)  et=parser.parse(endTime)  timedelta=et-st  returntimedelta.secondsiflen(sys.argv)==1:  o=untangle.parse('scripttest.xml')  print("No argument received, using scripttest.xml")else:  print("Argument received, using TestManagerReport.xml")  o=untangle.parse(    'TestManagerReport.xml')JunitTestCases=[]exitCode=0forCodesysTestCasesino.TestReport.Details.Sequence.TestCase:  codesysTCName=str(CodesysTestCases['Name'])  newTC=TestCase("","")  newTC.status=CodesysTestCases.Result['State']  newTC.elapsed_sec=getTimeTaken(CodesysTestCases.Timing.StartTime.cdata,CodesysTestCases.Timing.EndTime.cdata)  chunksByUnderscore=codesysTCName  chunksByUnderscore=chunksByUnderscore.split("_")  chunksByColon=codesysTCName  chunksByColon=chunksByColon.split(":")  ifchunksByUnderscore[0]=="FB":    newTC.classname=chunksByUnderscore[0]+"_"+chunksByUnderscore[1]    newTC.name=chunksByColon[1].strip()+":"+chunksByColon[2]  else:    newTC.name=chunksByUnderscore[0]    newTC.classname="Test Script"  ifCodesysTestCases.Result['State']=='Failed':    newTC.add_failure_info(CodesysTestCases.Result.AdditionalInformation.cdata)    exitCode=1  JunitTestCases.append(newTC)ts=TestSuite("Test Suite",JunitTestCases)withopen('junitreports.xml','w')asf:  TestSuite.to_file(f,[ts],prettyprint=True)ifexitCode!=0:  print("Failing Jenkins build due to test failure")sys.exit(exitCode)
Hello,
In this thread user Goof van de Weg mentioned that they had created a python script to convert exported Test Manager reports into a Junit format for Jenkins to recognize. As I don't believe he is active anymore I have created my own and wish to share it to those who would like to do the same.
Modify as you see fit - mine assumes that the test FBs are named FB_{FBNAME)_UNITTESTS and names the cases by each step of a multitest.
Install untangle, dateutil and junit_xml from pip or where ever you get your modules from
Related
Talk.ru: 1
Talk.ru: 2
Thank you!