Forum Discussion

palmerbw's avatar
palmerbw
Occasional Contributor
5 years ago

Adding fields to Summary Report

e are trying to import results into Zephyr. The parse can support several additional fields like Requirements ID and attachments. I have manually added them to the Summary XML and do an import with the Zbot Files watcher so I know they work. I cannot figure out how to get TestComplete to add the field to test cases in the Summary Report. Has anyone figured this out? 

  • 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

    • sonya_m's avatar
      sonya_m
      SmartBear Alumni (Retired)

      Thank you Justin! 

      palmerbw will this solution work for your case? 

      • palmerbw's avatar
        palmerbw
        Occasional Contributor

        Basically this indicates that I can write my own code to make two Smartbear tools communicate well. This does not seem like a good solution but I will accept it. 

  • AlexKaras's avatar
    AlexKaras
    Champion Level 3

    Hi,

     

    I am afraid that the Summary Report (likewise the log itself) is not extensible at the moment.

    You may create Support ticket (via the https://support.smartbear.com/message/?prod=TestComplete form) for the official reply and, hopefully, some piece of advice. I will appreciate it if you share reply from Support if they provide you with some workaround.

     

    • tristaanogre's avatar
      tristaanogre
      Esteemed Contributor

      I'm with AlexKaras .  The "stock" reports built in to TestComplete aren't so much reports as they are a data analysis of the logs.  Whatever the logs have in them, that drives what shows p on the reports and that includes specifics about test cases.

       

      As always, you can write out your own reports.  TestComplete has the capability of writing files such as CSV or Excel as well as inserting records into an SQL data table so, if you need something in more detail than what's available "out of the box", you can develop your own.  I know many users on this forum who have done so who might be willing to share their code.

      • sonya_m's avatar
        sonya_m
        SmartBear Alumni (Retired)

        Thank you Community!

         

        palmerbw were the suggestions helpful? Please let us know!