People always say that they need to add a lot of comments to explain complex logic or plentiful parameters, they forgot to look at the "keyword abstraction" feature of Keyword Driven approach, which means we could have different layers of keywords, which has different numbers of parameters and different flexibility. For example, having the keyword "Dig" as below, and using descriptive variable names, to make its usage clear; then encapsulate it with fixed parameters to be higher level user keywords like "Dig A Hole", which fixed the target to be a hole.
In this way, we sliced the functionality, and avoided writing enormous documentations which is unnecessary and troublesome.
|
|
alternative for upper one, I prefer this style
|
of the tests / user scenario of feature" and "how user
moves".
level.
table
[Arguments] | ${place} | ${tool} | |
Dig | ${place} | ${tool} | ${a hole} |
code
tool, hole):
above describes how we enable user’s moves.
maintains this need to know the details.
e.g.
${c} |
to add many comments, e.g.
${c} | // ${a} for where you dig, ${b} for the tool used, ${c} for what you
want to dig for
${target} |
they mean.
Another email discussion :
Team A made. and I understand it’s for all units. the detail implementation of
this user keyword as below
|
|
|
Units"
::FOR | ${unit} | IN | ${all units} |
| | Collect
Log Of Unit | ${unit}
|
Units"
|
|
|
// team B made a new keyword. Let’s refactor
those.
it means "after test executed" already, no need to repeat in the keyword
name.
units"
Alarms After Test Executed"
|
|
Of Unit | ${unit} |
Unit" | [Arguments] |
${unit} |
${unit} |
|
"Collect Logs And Alarms
After Test Executed" as:
|
|
Abstraction!
integrated, but perhaps not in such a forced way. Actually it’s about Common
Understanding. Keyword name is about purpose, the same purpose should have the
same name. If you have the keyword "Collect Logs Of Unit", it represents the
purpose to collect all logs of a single unit. If another engineer tries to
create a new keyword for this purpose, he / she should found this keyword, or
the tool (python? keyword documentation generation?) should told him/her
so.
Pingback:Keyword abstraction (robotframework) | Robot Framework中文站