Skip to content

Commit 993540e

Browse files
committed
Support SKIP status
1 parent 74a2e69 commit 993540e

File tree

8 files changed

+100
-44
lines changed

8 files changed

+100
-44
lines changed

README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Creates awesome HTML (dashboard view) report by parsing robotframework output.xm
1111
---
1212
- __Sample Report__ [link](https://robotmetrics.netlify.com/)
1313

14-
- Whats new in __v3.1.7__ [link](https://github.com/adiralashiva8/robotframework-metrics/releases/tag/v3.1.7)
14+
- Whats new in __v3.1.9__ [link](https://github.com/adiralashiva8/robotframework-metrics/releases/tag/v3.1.9)
1515

1616
- Source Code used to parse output.xml in metrics report [link](https://adiralashivaprasad.blogspot.com/2019/01/how-to-get-suite-test-and-keyword.html)
1717

@@ -33,7 +33,7 @@ __Step 1__ Install robotmetrics
3333

3434
> Case 1: Using pip
3535
```
36-
pip install robotframework-metrics==3.1.7
36+
pip install robotframework-metrics==3.1.9
3737
```
3838
> Case 2: Using setup.py (clone project and run command within root)
3939
```
@@ -208,4 +208,4 @@ If you have any questions / suggestions / comments on the report, please feel fr
208208
209209
:star: repo if you like it
210210
211-
---
211+
---

robotframework_metrics/keyword_results.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,12 @@ def start_keyword(self, kw):
4949
if kw_status == "PASS":
5050
table_td = self.soup.new_tag('td', style="color: green")
5151
table_td.string = kw_status
52-
else:
52+
elif kw_status == "FAIL":
5353
table_td = self.soup.new_tag('td', style="color: red")
5454
table_td.string = kw_status
55-
55+
else:
56+
table_td = self.soup.new_tag('td', style="color: orange")
57+
table_td.string = kw_status
5658
table_tr.insert(2, table_td)
5759

5860
table_td = self.soup.new_tag('td')

robotframework_metrics/keyword_stats.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ class KeywordStats(ResultVisitor):
55
total_keywords = 0
66
passed_keywords = 0
77
failed_keywords = 0
8+
skipped_keywords = 0
89

910
def __init__(self, ignore_library, ignore_type):
1011
self.ignore_library = ignore_library
@@ -24,5 +25,7 @@ def start_keyword(self, kw):
2425
self.total_keywords += 1
2526
if kw.status == "PASS":
2627
self.passed_keywords += 1
27-
else:
28+
elif kw.status == "FAIL":
2829
self.failed_keywords += 1
30+
else:
31+
self.skipped_keywords += 1

robotframework_metrics/robotmetrics.py

+56-24
Original file line numberDiff line numberDiff line change
@@ -236,9 +236,17 @@ def generate_report(opts):
236236
test_stats = TestStats()
237237
result.visit(test_stats)
238238

239-
total_suite = test_stats.total_suite
240-
passed_suite = test_stats.passed_suite
241-
failed_suite = test_stats.failed_suite
239+
try:
240+
test_stats_obj = test_stats.all
241+
except:
242+
test_stats_obj = test_stats
243+
total_suite = test_stats_obj.total_suite
244+
passed_suite = test_stats_obj.passed_suite
245+
failed_suite = test_stats_obj.failed_suite
246+
try:
247+
skipped_suite = test_stats_obj.skipped_suite
248+
except:
249+
skipped_suite = 0
242250

243251
#suitepp = round(passed_suite * 100.0 / total_suite, 1)
244252
#suitefp = round(failed_suite * 100.0 / total_suite, 1)
@@ -252,9 +260,17 @@ def generate_report(opts):
252260
generator = "Rebot"
253261

254262
stats = result.statistics
255-
total = stats.total.all.total
256-
passed = stats.total.all.passed
257-
failed = stats.total.all.failed
263+
try:
264+
stats_obj = stats.total.all
265+
except:
266+
stats_obj = stats.total
267+
total = stats_obj.total
268+
passed = stats_obj.passed
269+
failed = stats_obj.failed
270+
try:
271+
skipped = stats_obj.skipped
272+
except:
273+
skipped = 0
258274

259275
#testpp = round(passed * 100.0 / total, 1)
260276
#testfp = round(failed * 100.0 / total, 1)
@@ -265,6 +281,10 @@ def generate_report(opts):
265281
total_keywords = kw_stats.total_keywords
266282
passed_keywords = kw_stats.passed_keywords
267283
failed_keywords = kw_stats.failed_keywords
284+
try:
285+
skipped_keywords = kw_stats.skipped_keywords
286+
except:
287+
skipped_keywords = 0
268288

269289
# Handling ZeroDivisionError exception when no keywords are found
270290
# if total_keywords > 0:
@@ -313,10 +333,12 @@ def generate_report(opts):
313333
<tbody>
314334
<tr style="height:70%;font-size:25px" align="center" valign="middle">
315335
<td style="width: 33%; color:brown">__STOTAL__</td>
336+
<td style="width: 33%; color:orange">__SSKIP__</td>
316337
<td style="width: 33%; color:#fc6666">__SFAIL__</td>
317338
</tr>
318339
<tr style="height:30%" align="center" valign="top">
319340
<td style="width: 33%"><span style="color: #999999;font-size:10px">Total</span></td>
341+
<td style="width: 33%"><span style="color: #999999;font-size:10px">Skip</span></td>
320342
<td style="width: 33%"><span style="color: #999999;font-size:10px">Fail</span></td>
321343
</tr>
322344
</tbody>
@@ -352,10 +374,12 @@ def generate_report(opts):
352374
<tbody>
353375
<tr style="height:70%;font-size:25px" align="center" valign="middle">
354376
<td style="width: 33%; color:brown">__TTOTAL__</td>
377+
<td style="width: 33%; color:orange">__TSKIP__</td>
355378
<td style="width: 33%; color:#fc6666">__TFAIL__</td>
356379
</tr>
357380
<tr style="height:30%" align="center" valign="top">
358381
<td style="width: 33%"><span style="color: #999999;font-size:10px">Total</span></td>
382+
<td style="width: 33%"><span style="color: #999999;font-size:10px">Skip</span></td>
359383
<td style="width: 33%"><span style="color: #999999;font-size:10px">Fail</span></td>
360384
</tr>
361385
</tbody>
@@ -391,10 +415,12 @@ def generate_report(opts):
391415
<tbody>
392416
<tr style="height:70%;font-size:25px" align="center" valign="middle">
393417
<td style="width: 33%; color:brown">__KTOTAL__</td>
418+
<td style="width: 33%; color:orange">__KSKIP__</td>
394419
<td style="width: 33%; color:#fc6666">__KFAIL__</td>
395420
</tr>
396421
<tr style="height:30%" align="center" valign="top">
397422
<td style="width: 33%"><span style="color: #999999;font-size:10px">Total</span></td>
423+
<td style="width: 33%"><span style="color: #999999;font-size:10px">Skip</span></td>
398424
<td style="width: 33%"><span style="color: #999999;font-size:10px">Fail</span></td>
399425
</tr>
400426
</tbody>
@@ -452,14 +478,14 @@ def generate_report(opts):
452478
453479
<script>
454480
window.onload = function(){
455-
executeDataTable('#sm',5);
481+
executeDataTable('#sm',6);
456482
executeDataTable('#tm',3);
457483
executeDataTable('#km',3);
458-
createPieChart(__SPASS__,__SFAIL__,'suiteChartID','Suite Status:');
459-
createBarGraph('#sm',0,5,10,'suiteBarID','Elapsed Time (s) ','Suite');
460-
createPieChart(__TPASS__,__TFAIL__,'testChartID','Tests Status:');
484+
createPieChart(__SPASS__,__SFAIL__,__SSKIP__,'suiteChartID','Suite Status:');
485+
createBarGraph('#sm',0,6,10,'suiteBarID','Elapsed Time (s) ','Suite');
486+
createPieChart(__TPASS__,__TFAIL__,__TSKIP__,'testChartID','Tests Status:');
461487
createBarGraph('#tm',1,3,10,'testsBarID','Elapsed Time (s) ','Test');
462-
createPieChart(__KPASS__,__KFAIL__,'keywordChartID','Keywords Status:');
488+
createPieChart(__KPASS__,__KFAIL__,__KSKIP__,'keywordChartID','Keywords Status:');
463489
createBarGraph('#km',1,3,10,'keywordsBarID','Elapsed Time (s) ','Keyword');
464490
};
465491
</script>
@@ -479,12 +505,15 @@ def generate_report(opts):
479505
dashboard_content = dashboard_content.replace("__STOTAL__", str(total_suite))
480506
dashboard_content = dashboard_content.replace("__SPASS__", str(passed_suite))
481507
dashboard_content = dashboard_content.replace("__SFAIL__", str(failed_suite))
508+
dashboard_content = dashboard_content.replace("__SSKIP__", str(skipped_suite))
482509
dashboard_content = dashboard_content.replace("__TTOTAL__", str(total))
483510
dashboard_content = dashboard_content.replace("__TPASS__", str(passed))
484511
dashboard_content = dashboard_content.replace("__TFAIL__", str(failed))
512+
dashboard_content = dashboard_content.replace("__TSKIP__", str(skipped))
485513
dashboard_content = dashboard_content.replace("__KTOTAL__", str(total_keywords))
486514
dashboard_content = dashboard_content.replace("__KPASS__", str(passed_keywords))
487515
dashboard_content = dashboard_content.replace("__KFAIL__", str(failed_keywords))
516+
dashboard_content = dashboard_content.replace("__KSKIP__", str(skipped_keywords))
488517
dashboard_content = dashboard_content.replace("__KHIDE__", str(hide_keyword))
489518

490519
page_content_div.append(BeautifulSoup(dashboard_content, 'html.parser'))
@@ -538,17 +567,17 @@ def generate_report(opts):
538567
tr.insert(4, th)
539568

540569
th = soup.new_tag('th')
541-
th.string = "Time (s)"
570+
th.string = "Fail"
542571
tr.insert(5, th)
543572

573+
th = soup.new_tag('th')
574+
th.string = "Time (s)"
575+
tr.insert(6, th)
576+
544577
suite_tbody = soup.new_tag('tbody')
545578
table.insert(11, suite_tbody)
546579

547-
# GET SUITE METRICS
548-
if group:
549-
group.spawn(result.visit, SuiteResults(soup, suite_tbody, log_name, opts.fullsuitename))
550-
else:
551-
result.visit(SuiteResults(soup, suite_tbody, log_name, opts.fullsuitename))
580+
result.visit(SuiteResults(soup, suite_tbody, log_name, opts.fullsuitename))
552581

553582
test_icon_txt = """
554583
<div class="row">
@@ -614,10 +643,7 @@ def generate_report(opts):
614643
table.insert(11, test_tbody)
615644

616645
# GET TEST METRICS
617-
if group:
618-
group.spawn(result.visit, TestResults(soup, test_tbody, log_name, opts.fullsuitename, opts.showtags))
619-
else:
620-
result.visit(TestResults(soup, test_tbody, log_name, opts.fullsuitename, opts.showtags))
646+
result.visit(TestResults(soup, test_tbody, log_name, opts.fullsuitename, opts.showtags))
621647

622648
test_icon_txt = """
623649
<div class="row">
@@ -714,17 +740,17 @@ def generate_report(opts):
714740
# END OF LOGS
715741
script_text = """
716742
<script>
717-
function createPieChart(passed_count,failed_count,ChartID,ChartName){
743+
function createPieChart(passed_count, failed_count, skipped_count, ChartID, ChartName){
718744
var status = [];
719745
status.push(['Status', 'Percentage']);
720-
status.push(['PASS',parseInt(passed_count)],['FAIL',parseInt(failed_count)]);
746+
status.push(['PASS',parseInt(passed_count)],['FAIL',parseInt(failed_count)],['SKIP',parseInt(skipped_count)]);
721747
var data = google.visualization.arrayToDataTable(status);
722748
723749
var options = {
724750
pieHole: 0.6,
725751
legend: 'none',
726752
chartArea: {width: "95%",height: "90%"},
727-
colors: ['#2ecc71', '#fc6666'],
753+
colors: ['#2ecc71', '#fc6666', '#ffa500'],
728754
};
729755
730756
var chart = new google.visualization.PieChart(document.getElementById(ChartID));
@@ -824,6 +850,12 @@ def generate_report(opts):
824850
retrieve: true,
825851
"order": [[ Number(sortCol), "desc" ]],
826852
dom: 'l<".margin" B>frtip',
853+
"aoColumnDefs": [ {
854+
"aTargets": [ -1 ],
855+
"mRender": function ( data, type, full ) {
856+
return $("<div/>").html(data).text();
857+
}
858+
} ],
827859
buttons: [
828860
{
829861
extend: 'copyHtml5',

robotframework_metrics/suite_results.py

+22-8
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@ def start_suite(self, suite):
1414
if not suite_test_list:
1515
pass
1616
else:
17-
stats = suite.statistics
17+
try:
18+
stats = suite.statistics.all
19+
except:
20+
stats = suite.statistics
1821
table_tr = self.soup.new_tag('tr')
1922
self.tbody.insert(0, table_tr)
2023

@@ -32,24 +35,35 @@ def start_suite(self, suite):
3235
if suite_status == "PASS":
3336
table_td = self.soup.new_tag('td', style="color: green")
3437
table_td.string = suite_status
35-
else:
38+
elif suite_status == "FAIL":
3639
table_td = self.soup.new_tag('td', style="color: red")
3740
table_td.string = suite_status
41+
else:
42+
table_td = self.soup.new_tag('td', style="color: orange")
43+
table_td.string = suite_status
3844

3945
table_tr.insert(1, table_td)
4046

4147
table_td = self.soup.new_tag('td')
42-
table_td.string = str(stats.all.total)
48+
table_td.string = str(stats.total)
4349
table_tr.insert(2, table_td)
4450

45-
table_td = self.soup.new_tag('td')
46-
table_td.string = str(stats.all.passed)
51+
table_td = self.soup.new_tag('td', style="color: green")
52+
table_td.string = str(stats.passed)
4753
table_tr.insert(3, table_td)
4854

49-
table_td = self.soup.new_tag('td')
50-
table_td.string = str(stats.all.failed)
55+
table_td = self.soup.new_tag('td', style="color: red")
56+
table_td.string = str(stats.failed)
5157
table_tr.insert(4, table_td)
5258

59+
table_td = self.soup.new_tag('td', style="color: orange")
60+
try:
61+
skip_count = stats.skipped
62+
except:
63+
skip_count = 0
64+
table_td.string = str(skip_count)
65+
table_tr.insert(5, table_td)
66+
5367
table_td = self.soup.new_tag('td')
5468
table_td.string = str(suite.elapsedtime / float(1000))
55-
table_tr.insert(5, table_td)
69+
table_tr.insert(6, table_td)

robotframework_metrics/test_results.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -36,21 +36,23 @@ def visit_test(self, test):
3636
if test_status == "PASS":
3737
table_td = self.soup.new_tag('td', style="color: green")
3838
table_td.string = test_status
39-
else:
39+
elif test_status == "FAIL":
4040
table_td = self.soup.new_tag('td', style="color: red")
4141
table_td.string = test_status
42-
42+
else:
43+
table_td = self.soup.new_tag('td', style="color: orange")
44+
table_td.string = test_status
4345
table_tr.insert(2, table_td)
4446

4547
table_td = self.soup.new_tag('td')
4648
table_td.string = str(test.elapsedtime / float(1000))
4749
table_tr.insert(3, table_td)
4850

49-
table_td = self.soup.new_tag('td', style="word-wrap: break-word;max-width: 250px; white-space: normal;text-align:left")
51+
table_td = self.soup.new_tag('td', style="word-wrap: break-word;max-width: 250px; white-space: pre-wrap;text-align:left")
5052
table_td.string = test.message
5153
table_tr.insert(4, table_td)
5254

5355
if self.showtags == "True":
54-
table_td = self.soup.new_tag('td', style="word-wrap: break-word;max-width:100px; white-space: normal;text-align:left")
56+
table_td = self.soup.new_tag('td', style="word-wrap: break-word;max-width:100px; white-space: pre-wrap;text-align:left")
5557
table_td.string = str(test.tags)
5658
table_tr.insert(5, table_td)

robotframework_metrics/test_stats.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ class TestStats(ResultVisitor):
55
total_suite = 0
66
passed_suite = 0
77
failed_suite = 0
8+
skipped_suite = 0
89

910
def start_suite(self, suite):
1011
suite_test_list = suite.tests
@@ -15,5 +16,7 @@ def start_suite(self, suite):
1516

1617
if suite.status == "PASS":
1718
self.passed_suite += 1
18-
else:
19+
elif suite.status == "FAIL":
1920
self.failed_suite += 1
21+
else:
22+
self.skipped_suite += 1

robotframework_metrics/version.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "3.1.8"
1+
__version__ = "3.1.9"

0 commit comments

Comments
 (0)