| Issue 370: | Possibility to embed arguments into keyword names (e.g. `When user selects ${item} from list`) | |
| 2 people starred this issue and may be notified of changes. | Back to list |
Sign in to add a comment
|
Currently keywords can only get arguments so that they are specified after
the keyword name, but sometimes it would be more flexible to be able to
embed them into the keyword names. This is especially true when writing
higher level requirement-like tests (ATTD/BDD).
We might, for example, want to have keyword like `When user selects cat
from list` in one test and `When user selects dog from list` in another.
Currently these must be implemented as separate keywords, for example like
this (assuming that we have `Select from list` keyword available):
| When user selects cat from list | Select from list | cat |
| When user selects dog from list | Select from list | dog |
Instead of this, it would be great to be able to just have one keyword
`When user selects ${item} from list` implemented like:
| When user selects ${item} from list | Select from list | ${item} |
This would basically allow a second way to specify arguments for keywords.
These keywords should not be allowed to accept other arguments. At least in
the beginning it's probably enough to support this only with user keywords
and not with keywords implemented in libraries.
|
||||||||||||||
,
Jul 30, 2009
People familiar with Cucumber <http://cukes.info> have probably already realized that this feature is inspired by how arguments are passed to Cucumber's step definitions. I'm very happy to borrow good ideas from other tools/frameworks and I'm sure this approach will work great also in Robot Framework. |
|||||||||||||||
,
Jul 30, 2009
Issue 337 has been merged into this issue. |
|||||||||||||||
,
Aug 04, 2009
Juha and I have now implemented and tested this feature. Final code changes were committed in r2115. Documentation still needs to be added into the User Guide.
Status: Started
Cc: jprantan |
|||||||||||||||
,
Aug 04, 2009
Added a possibility to use also non-string variables as values for embedded arguments in r2123. That's a pretty obscure use case but the enhancement was trivial. I've also started the documentation by adding a simple example to the User Guide: http://robotframework.googlecode.com/svn/trunk/doc/userguide/RobotFrameworkUserGuide.html#embedding-arguments-to-keyword-name |
|||||||||||||||
,
Aug 06, 2009
Added more documentation in r2132 -- use the link in previous comment to see the generated HTML version. I still plan to format this documentation but comments about it are appreciated already now. |
|||||||||||||||
,
Aug 06, 2009
Realized that there's one case we haven't yet considered: It's possible that a
keyword that is used matches more than one user keyword with embedded arguments. If
we have, for example, keywords `Select ${a} or ${b}` and `Select ${x} and ${y}`, then
`Select this and that or whatever` will match both of them.
Because we cannot say which match is best and definitely shouldn't try to guess, I
believe we simply need to fail the test case if this happens, similarly as if there
were multiple keywords with same name. It must also be noted that in this "multi
match" scenario there can be multiple matching keywords in a single file. I believe
currently the first matching keyword would be selected so we need to both add new
tests for this scenario and then fix it.
|
|||||||||||||||
,
Aug 07, 2009
I'm starting to be pretty happy with the documentation. Latest version is linked below -- notice small change in anchor. Juha, Janne, and preferably also others, please review the doc and add comments here. Thanks! http://robotframework.googlecode.com/svn/trunk/doc/userguide/RobotFrameworkUserGuide.html#embedding-arguments-into-keyword-name In addition to finalizing the documentation we still need to take care of the problem of keyword matching multiple definitions that I explained in the previous comment. |
|||||||||||||||
,
Aug 10, 2009
This issue is now DONE. The problem with keyword matching multiple definitions has now been fixed and r2151 contains the final version. Some fixes were also done to the doc and further comments are still appreciated. One issue that was left open is in what format to log the keyword name. Currently the logged name is the one that is used in a test case (or higher level keyword) but with other keywords we use the one that is set when the keyword is created. I already changed this once, but because we currently construct keyword names stupidly (issue 377) the resulting name wasn't too good. The behavior can be changed as part of fixing issue 377.
Status: Done
|
|||||||||||||||
|
|
|||||||||||||||