2016-04-20 3:02 GMT+03:00 Bob Le <
ame...@gmail.com>:
> I'm noticing that when mixing positional and named arguments, Robot
> Framework is not detecting a bogus named argument.
You are right that bogus named argument are not detected. You don't
need to mix positional and named arguments, though. This is probably
the simplest example demonstrating the issue:
def keyword(arg):
print arg
*** Test Cases ***
Example
Keyword arg=foo # prints `foo`
Keyword foo=bar # prints `foo=bar`
The first usage of `Keyword` above uses the named argument syntax. It
is detected by Robot Framework because the passed in argument contains
`=` and the part before it matches an argument the keyword has. In the
latter usage there is not such match and thus `=` is considered to be
a literal value.
The reason for this behavior is that when the named argument syntax
was introduced in RF 2.5 [1], we didn't want to break existing tests
that used `=` as a literal value. Breaking backwards compatibility
would have been bad, but the current situation is not ideal either:
- As pointed out, the behavior is somewhat confusing.
- Typos when using the named argument syntax (e.g. `Keyword
argh=foo`) do not cause clear errors.
- When argument names are changed, named argument syntax usage breaks
without clear errors.
- When argument names are changed, new names may accidentally match
arguments where `=` is to be used literally.
I've encountered these problems many times enough to think that it
would be better if `=` would always mean named argument syntax and it
would need to be escaped like `\=` when used literally. The change
would be massively backwards incompatible, though, because `=` is used
so often in test data and many libraries also give it a special
meaning. For example, Selenium2Library uses `=` when specifying a
custom locator like `xpath=//h1` and `css=h1`.
In practice the change could only be done with a very long deprecation
period to give users time to escape `=` and library authors to come up
with alternative syntax to use instead of or in addition to it. Should
also consider adding a separate command line option to disable the
deprecation warning and possibly also to turn it into an error. All
this requires quite a bit of effort and I'm not sure is it worth it.
What do others think about this?
Cheers,
.peke
--
Agile Tester/Developer/Consultant ::
http://eliga.fi
Lead Developer of Robot Framework ::
http://robotframework.org