diff --git a/README.md b/README.md index a6cb6f9..17bb34e 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ Creates awesome HTML (dashboard view) report by parsing robotframework output.xm --- - __Sample Report__ [link](https://robotmetrics.netlify.com/) - - Whats new in __v3.2.0__ [link](https://github.com/adiralashiva8/robotframework-metrics/releases/tag/v3.2.0) + - Whats new in __v3.2.1__ [link](https://github.com/adiralashiva8/robotframework-metrics/releases/tag/v3.2.1) - 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) @@ -33,7 +33,7 @@ __Step 1__ Install robotmetrics > Case 1: Using pip ``` - pip install robotframework-metrics==3.2.0 + pip install robotframework-metrics==3.2.1 ``` > Case 2: Using setup.py (clone project and run command within root) ``` @@ -115,26 +115,6 @@ Specify Logo in Robotframework metrics: ``` > By default `--fullsuitename` is `False` - -#### How to Ignore Library Keywords in Metrics Report - - - Use command line options to ignore library keywords - ``` - --ignore "Collections,Selenium2Library" - ``` - - - In Metric report, keywords with type value 'for' and 'foritem' are ignored - - - Following library keywords are ignored in Metrics Report - ``` - ignore_library = [ - 'BuiltIn', - 'SeleniumLibrary', - 'String', - 'Collections', - 'DateTime', - ] - ``` --- #### Generate robotframework-metrics after execution diff --git a/robotframework_metrics/keyword_results.py b/robotframework_metrics/keyword_results.py index ee35fdc..d374ca1 100644 --- a/robotframework_metrics/keyword_results.py +++ b/robotframework_metrics/keyword_results.py @@ -3,11 +3,10 @@ class KeywordResults(ResultVisitor): - def __init__(self, soup, tbody, ignore_lib, ignore_type): + def __init__(self, soup, tbody, ignore_type): self.test = None self.soup = soup self.tbody = tbody - self.ignore_library = ignore_lib self.ignore_type = ignore_type def start_test(self, test): @@ -20,43 +19,37 @@ def start_keyword(self, kw): # Get test case name (Credits: Robotframework author - Pekke) test_name = self.test.name if self.test is not None else '' - # Ignore library keywords - keyword_library = kw.libname - - if any(library in keyword_library for library in self.ignore_library): + keyword_type = kw.type + if any(library in keyword_type for library in self.ignore_type): pass else: - keyword_type = kw.type - if any(library in keyword_type for library in self.ignore_type): - pass + table_tr = self.soup.new_tag('tr') + self.tbody.insert(1, table_tr) + + table_td = self.soup.new_tag('td', style="word-wrap: break-word;max-width: 250px; white-space: normal; text-align:left") + + if keyword_type != "kw": + table_td.string = str(kw.parent) else: - table_tr = self.soup.new_tag('tr') - self.tbody.insert(1, table_tr) - - table_td = self.soup.new_tag('td', style="word-wrap: break-word;max-width: 250px; white-space: normal; text-align:left") - - if keyword_type != "kw": - table_td.string = str(kw.parent) - else: - table_td.string = str(test_name) - table_tr.insert(0, table_td) - - table_td = self.soup.new_tag('td', style="word-wrap: break-word;max-width: 250px; white-space: normal; text-align:left") - table_td.string = kw.kwname - table_tr.insert(1, table_td) - - kw_status = str(kw.status) - if kw_status == "PASS": - table_td = self.soup.new_tag('td', style="color: green") - table_td.string = kw_status - elif kw_status == "FAIL": - table_td = self.soup.new_tag('td', style="color: red") - table_td.string = kw_status - else: - table_td = self.soup.new_tag('td', style="color: orange") - table_td.string = kw_status - table_tr.insert(2, table_td) - - table_td = self.soup.new_tag('td') - table_td.string = str(kw.elapsedtime / float(1000)) - table_tr.insert(3, table_td) \ No newline at end of file + table_td.string = str(test_name) + table_tr.insert(0, table_td) + + table_td = self.soup.new_tag('td', style="word-wrap: break-word;max-width: 250px; white-space: normal; text-align:left") + table_td.string = kw.kwname + table_tr.insert(1, table_td) + + kw_status = str(kw.status) + if kw_status == "PASS": + table_td = self.soup.new_tag('td', style="color: green") + table_td.string = kw_status + elif kw_status == "FAIL": + table_td = self.soup.new_tag('td', style="color: red") + table_td.string = kw_status + else: + table_td = self.soup.new_tag('td', style="color: orange") + table_td.string = kw_status + table_tr.insert(2, table_td) + + table_td = self.soup.new_tag('td') + table_td.string = str(kw.elapsedtime / float(1000)) + table_tr.insert(3, table_td) \ No newline at end of file diff --git a/robotframework_metrics/keyword_stats.py b/robotframework_metrics/keyword_stats.py index cc36494..b6fa173 100644 --- a/robotframework_metrics/keyword_stats.py +++ b/robotframework_metrics/keyword_stats.py @@ -7,25 +7,19 @@ class KeywordStats(ResultVisitor): failed_keywords = 0 skipped_keywords = 0 - def __init__(self, ignore_library, ignore_type): - self.ignore_library = ignore_library + def __init__(self, ignore_type): self.ignore_type = ignore_type def start_keyword(self, kw): - # Ignore library keywords - keyword_library = kw.libname - if any(library in keyword_library for library in self.ignore_library): + keyword_type = kw.type + if any(library in keyword_type for library in self.ignore_type): pass else: - keyword_type = kw.type - if any(library in keyword_type for library in self.ignore_type): - pass + self.total_keywords += 1 + if kw.status == "PASS": + self.passed_keywords += 1 + elif kw.status == "FAIL": + self.failed_keywords += 1 else: - self.total_keywords += 1 - if kw.status == "PASS": - self.passed_keywords += 1 - elif kw.status == "FAIL": - self.failed_keywords += 1 - else: - self.skipped_keywords += 1 + self.skipped_keywords += 1 diff --git a/robotframework_metrics/robotmetrics.py b/robotframework_metrics/robotmetrics.py index 9ee8991..3db5f56 100644 --- a/robotframework_metrics/robotmetrics.py +++ b/robotframework_metrics/robotmetrics.py @@ -21,7 +21,6 @@ except ImportError: FAILED_IMPORT = True -IGNORE_LIBRARIES = ['BuiltIn', 'SeleniumLibrary', 'String', 'Collections', 'DateTime'] IGNORE_TYPES = ['foritem', 'for'] @@ -33,11 +32,6 @@ def generate_report(opts): # URL or filepath of your company logo logo = opts.logo - # Ignores following library keywords in metrics report - ignore_library = IGNORE_LIBRARIES - if opts.ignore: - ignore_library.extend(opts.ignore) - # Ignores following type keywords in metrics report ignore_type = IGNORE_TYPES if opts.ignoretype: @@ -275,7 +269,7 @@ def generate_report(opts): #testpp = round(passed * 100.0 / total, 1) #testfp = round(failed * 100.0 / total, 1) - kw_stats = KeywordStats(ignore_library, ignore_type) + kw_stats = KeywordStats(ignore_type) result.visit(kw_stats) total_keywords = kw_stats.total_keywords @@ -704,10 +698,10 @@ def generate_report(opts): pass else: if group: - group.spawn(result.visit, KeywordResults(soup, kw_tbody, ignore_library, ignore_type)) + group.spawn(result.visit, KeywordResults(soup, kw_tbody, ignore_type)) group.join() else: - result.visit(KeywordResults(soup, kw_tbody, ignore_library, ignore_type)) + result.visit(KeywordResults(soup, kw_tbody, ignore_type)) test_icon_txt = """
diff --git a/robotframework_metrics/runner.py b/robotframework_metrics/runner.py index 3b1451a..3a8396c 100644 --- a/robotframework_metrics/runner.py +++ b/robotframework_metrics/runner.py @@ -2,7 +2,6 @@ import argparse from .robotmetrics import generate_report from .robotmetrics import IGNORE_TYPES -from .robotmetrics import IGNORE_LIBRARIES from .version import __version__ @@ -23,14 +22,6 @@ def parse_options(): help="User logo (default: dummy image )" ) - general.add_argument( - '--ignorelib', - dest='ignore', - default=IGNORE_LIBRARIES, - nargs="+", - help="Ignore keywords of specified library in report" - ) - general.add_argument( '--ignoretype', dest='ignoretype', diff --git a/robotframework_metrics/version.py b/robotframework_metrics/version.py index 30a0d3a..96af409 100644 --- a/robotframework_metrics/version.py +++ b/robotframework_metrics/version.py @@ -1 +1 @@ -__version__ = "3.2.0" \ No newline at end of file +__version__ = "3.2.1" \ No newline at end of file