palmerbw
This is just one simple solution:
first you need a script that will parse through your xml file to append the new tags of requirements and attachments
import sys
import xml.etree.ElementTree as ET
'''
This python script will attach file and one requirement to all of the test cases contained within the automation suite that was run via the zbot
You will include an additional call to this script within your batch file as a part of the same automation run
This .py file will take three command line arguments as explained below.
-------------------------------------
When calling the this python script from your batch file, provide additional command line arugments for these parameters
in the following order:
1) Your XML file generated by the automation run, its directory location, so that we can modify with additional sublemenets
2) the requirment to be mapped to all of the test cases within the automation job that just ran i.e AltID_JIRA-12
3) The location of the additional attachment to add (whatever file type, absolute path; i.e C:\\myAttachment.pdf)
-------------------------------------
your batch file will then look like (i.e for testcomplete tests)
<TC executable path> <TC project suite file> <runtime arguments ie. /r /e> </ExportSummary:"C:\\XML file location to be generated">
<python executable> <path to this .py file that will modify your xml file> <XML file location (from the /ExportSummary arugment)> <Your requirement i.e AltID_JIRA-12> <your attachment location>
'''
def add_att(myXMLfile, gen_req, attachment_location):
myXMLfile = str(myXMLfile)
gen_req = str(gen_req)
#Reading the file from disk:
tree = ET.parse(myXMLfile)
root = tree.getroot()
for testcase in root.iter('testcase'):
att_name = str(attachment_location) #"C:\\" + str(testcase.get('classname')) + ".mht"
#add in the attachments subelement for testcases
attachments1 = ET.SubElement(testcase, 'attachments')
attachments2 = ET.SubElement(attachments1, 'attachment')
attachments3 = ET.SubElement(attachments2, 'attachment')
attachments2.text = att_name
#add in the requirements subelements for test cases
requirements1 = ET.SubElement(testcase, 'requirements')
requirements2 = ET.SubElement(requirements1, 'requirement')
requirements3 = ET.SubElement(requirements2, 'requirement')
requirements2.text = gen_req
ET.dump(testcase)
#print(testcase.attrib)
tree.write(myXMLfile)
if __name__== "__main__":
add_att(str(sys.argv[1]), str(sys.argv[2]), str(sys.argv[3]))
then you need to call on this code to modify your junit xml file that's generated by TestComplete as a part of your batch file, so that you batch file now looks like:
<"Path to TestComplete.exe"> <"path to your TestComplete pjs file"> <additional arguments ie. /r /e /ExportSummary:"C:\myresults.xml">
<"path to your python exe"> <"path to that .py file above"> <C:\myresults.xml> <the requirement id> <path to your attachment>
----------------------
feel free to take that .py sample and modify it to fit your needs