html: add fail,error tables in html 70/238870/3
authorYeongjong Lee <yj34.lee@samsung.com>
Mon, 20 Jul 2020 04:06:27 +0000 (13:06 +0900)
committerYeongjong Lee <yj34.lee@samsung.com>
Mon, 20 Jul 2020 04:14:11 +0000 (13:14 +0900)
We can now check failure,error test cases at the top of html file.

Change-Id: I21cf8024062efc6fbc8700e6ef1394d402d762b0

TC/target_generation_html_report.py

index 4eb3e346eaeac116740110500214f7192044621f..bf65857130453f93e22e842aea15a5b48b90bfa7 100755 (executable)
@@ -24,6 +24,37 @@ def xml_tag_to_html_table(root):
        r.append(table)
        return r
 
+def xml_fail_tag_to_html_table(root):
+       if len(root.xpath('//*[@result="failure"]'))==0:
+               return [];
+
+       table = E.TABLE({'border':'1'},  E.TR(E.TH('Function line'), E.TH('Test case'),
+                                       E.TH("Result"), E.TH("Message"), E.TH("Duration"), bgcolor= "#d3d3d3"))
+       r = []
+       r += [E.P("Fail : " + str(len(root.xpath('//*[@result="failure"]'))), style="font-weight: bold; font-size: 120%")]
+       for i in root.xpath('//*[@result="failure"]'):
+          table.append(E.TR(E.TD(i.find('fn').text), E.TD(i.find('id').text), E.TD(i.attrib['result']),
+                         E.TD(i.find('message').text), E.TD(i.find('duration').text), bgcolor = table_in_color(i.attrib['result'])))
+
+       r.append(table)
+       return r
+
+def xml_error_tag_to_html_table(root):
+       if len(root.xpath('//*[@result="error"]'))==0:
+               return [];
+
+       table = E.TABLE({'border':'1'},  E.TR(E.TH('Function line'), E.TH('Test case'),
+                                       E.TH("Result"), E.TH("Message"), E.TH("Duration"), bgcolor= "#d3d3d3"))
+       r = []
+       r += [E.P("Error : " + str(len(root.xpath('//*[@result="error"]'))), style="font-weight: bold; font-size: 120%")]
+       for i in root.xpath('//*[@result="error"]'):
+          table.append(E.TR(E.TD(i.find('fn').text), E.TD(i.find('id').text), E.TD(i.attrib['result']),
+                                                       E.TD(i.find('message').text), E.TD(i.find('duration').text), bgcolor = table_in_color(i.attrib['result'])))
+
+       r.append(table)
+       return r
+
+
 with open(sys.argv[1],'r') as f: e = fromstring(f.read())
 
 html = E.HTML(
@@ -51,6 +82,13 @@ html = E.HTML(
                )
        )
 
+
+for i in xml_fail_tag_to_html_table(e):
+       html.body.append(i)
+
+for i in xml_error_tag_to_html_table(e):
+       html.body.append(i)
+
 for i in e.xpath('//suite'):
        for j in xml_tag_to_html_table(i):
                html.body.append(j)