Skip to content

Commit bbbb513

Browse files
committed
Fix issues with rf4.0
1 parent bd096c4 commit bbbb513

File tree

6 files changed

+47
-95
lines changed

6 files changed

+47
-95
lines changed

README.md

Lines changed: 2 additions & 22 deletions
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.2.0__ [link](https://github.com/adiralashiva8/robotframework-metrics/releases/tag/v3.2.0)
14+
- Whats new in __v3.2.1__ [link](https://github.com/adiralashiva8/robotframework-metrics/releases/tag/v3.2.1)
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.2.0
36+
pip install robotframework-metrics==3.2.1
3737
```
3838
> Case 2: Using setup.py (clone project and run command within root)
3939
```
@@ -115,26 +115,6 @@ Specify Logo in Robotframework metrics:
115115
```
116116
> By default `--fullsuitename` is `False`
117117
118-
119-
#### How to Ignore Library Keywords in Metrics Report
120-
121-
- Use command line options to ignore library keywords
122-
```
123-
--ignore "Collections,Selenium2Library"
124-
```
125-
126-
- In Metric report, keywords with type value 'for' and 'foritem' are ignored
127-
128-
- Following library keywords are ignored in Metrics Report
129-
```
130-
ignore_library = [
131-
'BuiltIn',
132-
'SeleniumLibrary',
133-
'String',
134-
'Collections',
135-
'DateTime',
136-
]
137-
```
138118
---
139119
140120
#### Generate robotframework-metrics after execution

robotframework_metrics/keyword_results.py

Lines changed: 32 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,10 @@
33

44
class KeywordResults(ResultVisitor):
55

6-
def __init__(self, soup, tbody, ignore_lib, ignore_type):
6+
def __init__(self, soup, tbody, ignore_type):
77
self.test = None
88
self.soup = soup
99
self.tbody = tbody
10-
self.ignore_library = ignore_lib
1110
self.ignore_type = ignore_type
1211

1312
def start_test(self, test):
@@ -20,43 +19,37 @@ def start_keyword(self, kw):
2019
# Get test case name (Credits: Robotframework author - Pekke)
2120
test_name = self.test.name if self.test is not None else ''
2221

23-
# Ignore library keywords
24-
keyword_library = kw.libname
25-
26-
if any(library in keyword_library for library in self.ignore_library):
22+
keyword_type = kw.type
23+
if any(library in keyword_type for library in self.ignore_type):
2724
pass
2825
else:
29-
keyword_type = kw.type
30-
if any(library in keyword_type for library in self.ignore_type):
31-
pass
26+
table_tr = self.soup.new_tag('tr')
27+
self.tbody.insert(1, table_tr)
28+
29+
table_td = self.soup.new_tag('td', style="word-wrap: break-word;max-width: 250px; white-space: normal; text-align:left")
30+
31+
if keyword_type != "kw":
32+
table_td.string = str(kw.parent)
3233
else:
33-
table_tr = self.soup.new_tag('tr')
34-
self.tbody.insert(1, table_tr)
35-
36-
table_td = self.soup.new_tag('td', style="word-wrap: break-word;max-width: 250px; white-space: normal; text-align:left")
37-
38-
if keyword_type != "kw":
39-
table_td.string = str(kw.parent)
40-
else:
41-
table_td.string = str(test_name)
42-
table_tr.insert(0, table_td)
43-
44-
table_td = self.soup.new_tag('td', style="word-wrap: break-word;max-width: 250px; white-space: normal; text-align:left")
45-
table_td.string = kw.kwname
46-
table_tr.insert(1, table_td)
47-
48-
kw_status = str(kw.status)
49-
if kw_status == "PASS":
50-
table_td = self.soup.new_tag('td', style="color: green")
51-
table_td.string = kw_status
52-
elif kw_status == "FAIL":
53-
table_td = self.soup.new_tag('td', style="color: red")
54-
table_td.string = kw_status
55-
else:
56-
table_td = self.soup.new_tag('td', style="color: orange")
57-
table_td.string = kw_status
58-
table_tr.insert(2, table_td)
59-
60-
table_td = self.soup.new_tag('td')
61-
table_td.string = str(kw.elapsedtime / float(1000))
62-
table_tr.insert(3, table_td)
34+
table_td.string = str(test_name)
35+
table_tr.insert(0, table_td)
36+
37+
table_td = self.soup.new_tag('td', style="word-wrap: break-word;max-width: 250px; white-space: normal; text-align:left")
38+
table_td.string = kw.kwname
39+
table_tr.insert(1, table_td)
40+
41+
kw_status = str(kw.status)
42+
if kw_status == "PASS":
43+
table_td = self.soup.new_tag('td', style="color: green")
44+
table_td.string = kw_status
45+
elif kw_status == "FAIL":
46+
table_td = self.soup.new_tag('td', style="color: red")
47+
table_td.string = kw_status
48+
else:
49+
table_td = self.soup.new_tag('td', style="color: orange")
50+
table_td.string = kw_status
51+
table_tr.insert(2, table_td)
52+
53+
table_td = self.soup.new_tag('td')
54+
table_td.string = str(kw.elapsedtime / float(1000))
55+
table_tr.insert(3, table_td)

robotframework_metrics/keyword_stats.py

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,19 @@ class KeywordStats(ResultVisitor):
77
failed_keywords = 0
88
skipped_keywords = 0
99

10-
def __init__(self, ignore_library, ignore_type):
11-
self.ignore_library = ignore_library
10+
def __init__(self, ignore_type):
1211
self.ignore_type = ignore_type
1312

1413
def start_keyword(self, kw):
15-
# Ignore library keywords
16-
keyword_library = kw.libname
1714

18-
if any(library in keyword_library for library in self.ignore_library):
15+
keyword_type = kw.type
16+
if any(library in keyword_type for library in self.ignore_type):
1917
pass
2018
else:
21-
keyword_type = kw.type
22-
if any(library in keyword_type for library in self.ignore_type):
23-
pass
19+
self.total_keywords += 1
20+
if kw.status == "PASS":
21+
self.passed_keywords += 1
22+
elif kw.status == "FAIL":
23+
self.failed_keywords += 1
2424
else:
25-
self.total_keywords += 1
26-
if kw.status == "PASS":
27-
self.passed_keywords += 1
28-
elif kw.status == "FAIL":
29-
self.failed_keywords += 1
30-
else:
31-
self.skipped_keywords += 1
25+
self.skipped_keywords += 1

robotframework_metrics/robotmetrics.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
except ImportError:
2222
FAILED_IMPORT = True
2323

24-
IGNORE_LIBRARIES = ['BuiltIn', 'SeleniumLibrary', 'String', 'Collections', 'DateTime']
2524
IGNORE_TYPES = ['foritem', 'for']
2625

2726

@@ -33,11 +32,6 @@ def generate_report(opts):
3332
# URL or filepath of your company logo
3433
logo = opts.logo
3534

36-
# Ignores following library keywords in metrics report
37-
ignore_library = IGNORE_LIBRARIES
38-
if opts.ignore:
39-
ignore_library.extend(opts.ignore)
40-
4135
# Ignores following type keywords in metrics report
4236
ignore_type = IGNORE_TYPES
4337
if opts.ignoretype:
@@ -275,7 +269,7 @@ def generate_report(opts):
275269
#testpp = round(passed * 100.0 / total, 1)
276270
#testfp = round(failed * 100.0 / total, 1)
277271

278-
kw_stats = KeywordStats(ignore_library, ignore_type)
272+
kw_stats = KeywordStats(ignore_type)
279273
result.visit(kw_stats)
280274

281275
total_keywords = kw_stats.total_keywords
@@ -704,10 +698,10 @@ def generate_report(opts):
704698
pass
705699
else:
706700
if group:
707-
group.spawn(result.visit, KeywordResults(soup, kw_tbody, ignore_library, ignore_type))
701+
group.spawn(result.visit, KeywordResults(soup, kw_tbody, ignore_type))
708702
group.join()
709703
else:
710-
result.visit(KeywordResults(soup, kw_tbody, ignore_library, ignore_type))
704+
result.visit(KeywordResults(soup, kw_tbody, ignore_type))
711705

712706
test_icon_txt = """
713707
<div class="row">

robotframework_metrics/runner.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import argparse
33
from .robotmetrics import generate_report
44
from .robotmetrics import IGNORE_TYPES
5-
from .robotmetrics import IGNORE_LIBRARIES
65
from .version import __version__
76

87

@@ -23,14 +22,6 @@ def parse_options():
2322
help="User logo (default: dummy image )"
2423
)
2524

26-
general.add_argument(
27-
'--ignorelib',
28-
dest='ignore',
29-
default=IGNORE_LIBRARIES,
30-
nargs="+",
31-
help="Ignore keywords of specified library in report"
32-
)
33-
3425
general.add_argument(
3526
'--ignoretype',
3627
dest='ignoretype',

robotframework_metrics/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "3.2.0"
1+
__version__ = "3.2.1"

0 commit comments

Comments
 (0)