Reputation: 51
If a robotframework project has keywords that spreads out in several folders (e.g., in resource and library files), is there a utility to list all user-defined keywords along with the lower level keywords invoked ?
This utility is similar to how the 'cflow' utility parses all c source files and produce a database file.
Upvotes: 5
Views: 6009
Reputation:
Using robot framework api we can get KEYWORD Metrics
Reference:Link
API: class robot.result.model.Keyword
# Keyword Metrics Code: (save following snippet as python file and execute)
from robot.api import ExecutionResult,ResultVisitor
result = ExecutionResult('output.xml')
result.configure(stat_config={'suite_stat_level': 2,
'tag_stat_combine': 'tagANDanother'})
class KeywordMetrics(ResultVisitor):
def visit_keyword(self,kw):
print "Keyword Name: " + str(kw.name)
print "Keyword Status: " + str(kw.status)
print "Keyword Starttime: " + str(kw.starttime)
print "Keyword Endtime: " + " " + str(kw.endtime)
print "Keyword Elapsedtime (Sec): " + " " + str(kw.elapsedtime/float(1000))
result.visit(KeywordMetrics())
Robot framework Metrics project is implemented to show metrics result in HTML format with dashboard view.
Upvotes: 3
Reputation: 786
There is no such tool but can be made pretty quickly. Rflint has a parser,which can iterate over testsuites to get list of keywords and testcases used in robot file. If you can generate a structure that links keywords usage to testcases/testsuites,you will get at least stats from Robot defined KW.
Sample snipped from GitHub/RED, parse_rf_file(parent_filename) is a good starting point. https://github.com/nokia/RED/blob/master/misc/nilsimsa_POC/nilsimsa_POC.py
Rflint GitHub page: https://github.com/boakley/robotframework-lint
Upvotes: 0
Reputation: 6961
In my mind this question can be answered two fold:
If option 2 is the desired outcome, then familiarize yourself with the Robot Framework LibDoc Library Documentation tool. Aside from libraries, you can also document resource robot files that contain your own keywords.
There are two output possibilities: HTML and XML. So, if your end goal is to pull certain information from the file for further processing, I'd recommend XML.
Upvotes: 0
Reputation: 385970
There is no such tool. Though, you could write your own by creating a listener that records each keyword as it runs.
Upvotes: 0